我在使用htaccess时遇到了麻烦,因为我想让我的网址SEO友好。 这一切都很好但我不能在不使用.php的情况下继续使用URL

我的网址是:

http://rasolutions.eu/blogitem?id=3

我希望它是:

http://rasolutions.eu/blogitem/3/

我在网上搜索过,我编写的代码使它工作,唯一的问题是我不能去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

非常感谢您的帮助! 对不起英语不好,这不是我的母语。

===============>>#1 票数:1 已采纳

尝试这个:

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

多视图应该允许Apache搜索最接近的匹配,例如没有“.php”扩展名。

祝你好运!

===============>>#2 票数:1

它是这样的:

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]

  ask by RezaM translate from so

未解决问题?本站智能推荐: