Hans Wassink
Hans Wassink

Reputation: 2577

htaccess rewrite problem in IE

I am fiddling around with .htaccess and mod_rewrite. I have a site that has two types of URLs which I rewrote:

I rewrote them to:

I already made a piece of code that works (below), I had some help from the community, but the weird thing is that http://www.mydomain.nl/projects/15 works fine in FF, Chrome and safari, but it gives "page cant be displayed" in IE. Does htaccess work differently in different browsers? (I highly doubt it)

Options +FollowSymlinks
RewriteEngine on

# Reroute rules that end on / 
RewriteRule ^(.*)\/(\d+) /$1/$2/ [R] 
# RewriteRule ^(.*)\/(.*)\/(\d+) /$1/$2/$3/ [R] 

# Make the system understand pagename/96
RewriteRule ^(.*)\/(\d+)/ /index.php?nav=$2 

# Make the system understand news/pagename/99
RewriteRule ^(.*)\/(.*)\/(\d+)/ /index.php?nav=41&intNewsId=$3

I solved the problem, but Im unsure why this does work, and the previous code doesnt. I fixed two things: I removed the starting / from /index.php... That didnt solve it, but it's less bytes :D

Then I rewrote the /-rerouting rule, this fixed it...

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://mydomain.nl/$1/ [L,R=301] 

RewriteRule ^(.*)\/(\d+)/ index.php?nav=$2 

RewriteRule ^(.*)\/(.*)\/(\d+)/ index.php?nav=41&intNewsId=$3

Thanks all!

Upvotes: 0

Views: 3434

Answers (1)

Hans Wassink
Hans Wassink

Reputation: 2577

I solved the problem, but Im unsure why this does work, and the previous code doesnt. I fixed two things: I removed the starting / from /index.php... That didnt solve it, but it's less bytes :D

Then I rewrote the /-rerouting rule, this fixed it...

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://mydomain.nl/$1/ [L,R=301] 

RewriteRule ^(.*)\/(\d+)/ index.php?nav=$2 

RewriteRule ^(.*)\/(.*)\/(\d+)/ index.php?nav=41&intNewsId=$3

Upvotes: 1

Related Questions