Reputation: 167
Sorry for the bad English, English isn't my mother tongue so I'm trying to make the best of it.
I'm having trouble with mod_rewrite when I try to make my URL seo friendlier. I won't to make my URL from this:
http://domain.eu/blog?page=2
To this:
http://domain.eu/blog/2/
My current code:
ErrorDocument 404 /404.php
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
# WWW to not WWW.
#RewriteCond %{HTTP_HOST} ^www\.rasolutions\.eu$
#RewriteRule ^/?$ "http\:\/\/rasolutions\.eu\/" [R=301]
# No PERL access/
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
# Blog SEO Urls.
RewriteRule ^blog/([0-9]*)/?$ blog.php?page=$1 [NC,L]
RewriteRule ^blogitem/([0-9]*)/?$ blogitem.php?id=$1 [NC,L]
# Home redirect.
DirectoryIndex home.php
Upvotes: 0
Views: 401
Reputation: 7881
First of all - make sure you've turned mod_rewrite
on in the .htaccess file by stating
RewriteEngine on
If that was already set make sure you have Multiviews
option disabled by setting
Options -Multiviews
on the server's configuration file
A similar question: mod_rewrite not passing querystring
Now that I see your full .htaccess - the order of rules there is wrong
you should first check:
# Blog SEO Urls.
RewriteRule ^blog/([0-9]*)/?$ blog.php?page=$1 [NC,L]
RewriteRule ^blogitem/([0-9]*)/?$ blogitem.php?id=$1 [NC,L]
and only after that
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
The full file should look like this:
ErrorDocument 404 /404.php
# Home redirect.
DirectoryIndex home.php
Options -MultiViews
RewriteEngine On
# No PERL access/
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
# WWW to not WWW.
#RewriteCond %{HTTP_HOST} ^www\.rasolutions\.eu$
#RewriteRule ^/?$ "http\:\/\/rasolutions\.eu\/" [R=301]
# Blog SEO Urls.
RewriteRule ^blog/([0-9]*)/?$ blog.php?page=$1 [NC,L]
RewriteRule ^blogitem/([0-9]*)/?$ blogitem.php?id=$1 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
Upvotes: 1