[英]htaccess mod_rewrite without .php
I'm having trouble with htaccess because I would like to have my URLs SEO friendly. 我在使用htaccess时遇到了麻烦,因为我想让我的网址SEO友好。 And that's all good but I can't go on the URL without using .php
这一切都很好但我不能在不使用.php的情况下继续使用URL
My URL is: 我的网址是:
http://rasolutions.eu/blogitem?id=3
And I want it to be: 我希望它是:
http://rasolutions.eu/blogitem/3/
I've searched online and I've written code that made it work, the only problem is that I can't go to the URL unless I use .php My htaccess code is this(I'm a noob if it comes to htaccess): 我在网上搜索过,我编写的代码使它工作,唯一的问题是我不能去URL,除非我使用.php我的htaccess代码就是这个(如果是htaccess,我就是一个菜鸟):
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,L]
# No PERL access/
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
RewriteEngine On
RewriteRule ^blogitem/([0-9]+)/$ blogitem.php?id=$1 [NC,L]
RewriteEngine On
RewriteRule ^blog/([0-9]+)/$ blog.php?page=$1 [NC,L]
# Home redirect.
DirectoryIndex home.php
Thank you very much for helping! 非常感谢您的帮助! Sorry for the bad English, it isn't my mother tongue.
对不起英语不好,这不是我的母语。
Try this: 尝试这个:
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,L]
# No PERL access/
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
RewriteEngine On
RewriteRule ^blogitem/([0-9]+)/$ blogitem.php?id=$1 [NC,L]
RewriteEngine On
RewriteRule ^blog/([0-9]+)/$ blog.php?page=$1 [NC,L]
# Home redirect.
DirectoryIndex home.php
Multiviews should allow Apache to search out a nearest match, eg without the ".php" extension. 多视图应该允许Apache搜索最接近的匹配,例如没有“.php”扩展名。
Best of luck! 祝你好运!
Have it 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%{REQUEST_URI} [R=301,L,NE]
RewriteRule ^blogitem/([0-9]+)/?$ blogitem.php?id=$1 [NC,L,QSA]
RewriteRule ^blog/([0-9]+)/?$ blog.php?page=$1 [NC,L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.php [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.