Question

I'm trying to redirect URL like this

http://localhost/web/gallery/dogs

to

http://localhost/web/index.php?section=gallery&name=dogs

To do that, I try with the next .htaccess

RewriteBase /

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^gallery/(.*)$ index.php/?section=gallery&name=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/?section=$1 [L]

</IfModule>

I have the next problem, if I write the URL manually, it looks well with correct CSS and without errors. Else, if I use first URL, firefox give me MIME type error with CSS and other files, so, it appears like an old without colors web.

Nobody know how I can solve this?

Thank you!!

Edit:

I'm trying now it online, and happen the same. I don't change anything.

If I try this URL

http://alexander.comyr.com/gallery&name=Historias_del_mar

it goes well, else, trying this:

http://alexander.comyr.com/gallery/Historias_del_mar

it doesn't work properly

Was it helpful?

Solution

Sounds like you need to either make your CSS links absolute, so that they start with /web/ or add the relative URI base to the header of your page:

<base href="/web/" />

Or if your URI base is just / (as it appears to be in your htaccess file), then:

<base href="/" />

OTHER TIPS

It seems your css file are being rewritten.

On your http://alexander.comyr.com/gallery/Historias_del_mar page, the CSS files redirect to http://alexander.comyr.com/gallery/css/foundation.css. They should be going to http://alexander.comyr.com/css/foundation.css

So I would try exluding CSS files from your rewrites, like adding the following condition to your rules:

ReWriteCond %{REQUEST_URI} !^.*\.css$
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top