.htaccess单变量url重写

.htaccess单变量url重写,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我正在尝试重定向到使用htaccess。但是,它一直在此处重定向:。我到处找答案,但似乎找不到。我真的很感激你能帮我解决这个问题,谢谢 这是我的.htaccess文件 Options +FollowSymlinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.pearlsquirrel.com$ [NC] RewriteRule ^(.*)$ http://pearlsquirrel.com/$1 [L,R=301

我正在尝试重定向到使用htaccess。但是,它一直在此处重定向:。我到处找答案,但似乎找不到。我真的很感激你能帮我解决这个问题,谢谢

这是我的.htaccess文件

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.pearlsquirrel.com$ [NC]
RewriteRule ^(.*)$ http://pearlsquirrel.com/$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php

RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+) explore_all?u=$1 [L]
你可以试试这个:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING}  [^=]+=([^=]+)
RewriteRule .* /%1? [L]
将映射以下内容:

http://test.pearlsquirrel.com/explore_all?u=hiphop

为此:

http://test.pearlsquirrel.com/explore_all/hiphop

用此代码替换.htaccess文件中的相应代码

我没有检查你的.htaccess文件中的规则

选项

现在,如果是另一种方式,我认为是这样的,我们的想法是映射这个传入的URL:

http://test.pearlsquirrel.com/explore_all/hiphop

对于此资源:

http://test.pearlsquirrel.com/explore_all?u=hiphop

将上述规则集替换为以下规则集:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}  .*/([^/]+)/?
RewriteRule .* http://test.pearlsquirrel.com/explore_all?u=%1 [L] 

这似乎仍然不能解决问题。当我尝试转到链接时,出现404未找到错误。
/hiphop
目录是否存在?你说:
http://test.pearlsquirrel.com/explore_all?u=hiphop
http://test.pearlsquirrel.com/explore_all/hiphop
,我想应该是相反的。浏览器地址栏中显示的URL应为:
http://test.pearlsquirrel.com/explore_all/hiphop
不是第一个,但我刚刚回答了你的问题。如果是这样,请更新您的问题,我将很乐意更新我的答案。该目录不存在。目录是否应该存在?很抱歉造成任何混乱。请看我之前的评论。我认为你想要的与你要求的相反。我会更新答案的。哦,好的。非常感谢你!