【问题标题】:Pretty url index page漂亮的 url 索引页面
【发布时间】:2014-04-14 22:55:52
【问题描述】:

我只有 first 漂亮的 url 工作。我没有让第二和第三个工作,他们只是显示一个混乱的页面(未加载样式)+它显示错误的页面

这是我的代码:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.*)$ index.php?tab=$1 [NC]
RewriteRule ^/ucp(.*)$ index.php?ucp&tab=$1 [NC]
RewriteRule ^/ucp(.*)$ index.php?ucp [NC,L]

.

Possible urls:
http://subdomain.domain.com/path2files/index.php?&tab=str
http://subdomain.domain.com/path2files/index.php?ucp
http://subdomain.domain.com/path2files/index.php?ucp&tab=str

How they should look like:
http://subdomain.domain.com/path2files/str
http://subdomain.domain.com/path2files/ucp
http://subdomain.domain.com/path2files/ucp/str

【问题讨论】:

  • 那怎么了?您一直在编辑问题中的内容吗?
  • 对不起。我在编辑这个时遇到了一些问题:(我现在已经做了最后的编辑。

标签: .htaccess url mod-rewrite url-rewriting


【解决方案1】:

试试这个:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /path2files/index\.php\?ucp&tab=(.*)\ HTTP
RewriteRule ^ /path2files/ucp/%2\? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^path2files/ucp/(.*)$ /path2files/index.php?ucp&tab=$1 [L]


RewriteCond %{THE_REQUEST} ^(GET|POST)\ /path2files/index\.php\?ucp\ HTTP
RewriteRule ^ /path2files/ucp\? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^path2files/ucp$ /path2files/index.php?ucp [L]

RewriteCond %{THE_REQUEST} ^(GET|POST)\ /path2files/index\.php\?&tab=(.*)\ HTTP
RewriteRule ^ /path2files/%2\? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^/ucp
RewriteRule ^path2files/(.*)$ /path2files/index.php?&tab=$1 [L]

【讨论】:

  • 每当我在 tab_name 之后添加一个额外的 / 时,页面看起来很乱(没有 css)并且 .../ ucp/tab_name 显示一个混乱的页面,最后有或没有 /
猜你喜欢
  • 2018-02-07
  • 2014-01-25
  • 1970-01-01
  • 2019-06-20
  • 1970-01-01
  • 2013-06-16
  • 2019-02-08
  • 1970-01-01
  • 2011-03-27
相关资源
最近更新 更多