带有 .htacces 的友好 URL 来自我的网络托管的奇怪响应...帮助
我只是希望当它插入到 URL 中时:
http://website.com/pelicula/0221889/
http://website.com/pelicula/0221889/posters/
它确实会变成这样(在后台):
http://website.com/index.php?ctrl=pelicula&id=0160399
http://website.com/index.php?ctrl=pelicula&id=0160399&tab=posters
所以我将其放入我的 .htaccess 文件中:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/([^/]+)/([^/]+)/?([^/]*)/?$ index.php?ctrl=$1&id=$2&tab=$3 [QSA,L]
</IfModule>
但它在我的网络主机中不起作用,所以我向他们的支持团队寻求帮助这是他们的回应:
<IfModule mod_rewrite.c>
RewriteEngine On
# If subdomain www exists, remove it first
#RewriteCond %{HTTP_HOST} ^www.([^.]+.[^.]+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# If requested resource does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# and does not end with a period followed by a filetype
RewriteCond %{REQUEST_URI} !..+$
# and does not end with a slash
RewriteCond %{REQUEST_URI} !/$
# then add a trailing slash and redirect
RewriteRule (.*) $1/ [R=301,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
显然它没有按预期工作,所以我只想知道如何解决这个问题!我对 mod_rewrite 一无所知,我真的需要它才能完美工作...我要疯了,我不知道问题出在哪里..请帮忙!
I just wanted that when this is inserted in the URL:
http://website.com/pelicula/0221889/
http://website.com/pelicula/0221889/posters/
It really goes to this (in background):
http://website.com/index.php?ctrl=pelicula&id=0160399
http://website.com/index.php?ctrl=pelicula&id=0160399&tab=posters
So I put this in my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/([^/]+)/([^/]+)/?([^/]*)/?$ index.php?ctrl=$1&id=$2&tab=$3 [QSA,L]
</IfModule>
But it was not working in my web host so I asked for help from their support team and this was their response:
<IfModule mod_rewrite.c>
RewriteEngine On
# If subdomain www exists, remove it first
#RewriteCond %{HTTP_HOST} ^www.([^.]+.[^.]+)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# If requested resource does not exist as a file
RewriteCond %{REQUEST_FILENAME} !-f
# and does not end with a period followed by a filetype
RewriteCond %{REQUEST_URI} !..+$
# and does not end with a slash
RewriteCond %{REQUEST_URI} !/$
# then add a trailing slash and redirect
RewriteRule (.*) $1/ [R=301,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Obviously its not working as desired so I just want to know how to fix this!!! I don't know nothing about mod_rewrite and I really need this to work perfectly... I'm going mad I don't know where is the problem.. please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
支持人员似乎刚刚向您发送了他们在知识库中找到的第一个 URL 重写代码作为示例。这很正常:世界上没有托管服务可以提供免费咨询服务:)
我建议您尽量保持简单:
It seems that the support guys just sent you the first URL-rewriting code they found in their knowledge base to serve as sample. And it's normal: no hosting service in the world can provide free consulting services :)
I suggest you try to keep it simple: