【问题标题】:htaccess skip part of the URLhtaccess 跳过部分 URL
【发布时间】:2016-10-16 12:34:56
【问题描述】:

我有一个像 http://example.com/interview/folder1/folder2/xxx 这样的长 URL。我还需要像http://example.com/interview/xxx 这样的简短形式打开该页面。 这个我试过了,没用

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteCond %{REQUEST_URI} !^interview/folder1/folder2/
    RewriteRule (.*) interview/$1

请注意,这是从更大的 htaccess 中摘录的。 我做错了什么?

【问题讨论】:

  • htaccess 在哪里?
  • htaccess 位于网站根目录下。

标签: php .htaccess magento mod-rewrite


【解决方案1】:

你可以试试这个.htaccess文件:

RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^interview/folder1/folder2/
RewriteRule ^interview/(.*)$ /interview/folder1/folder2/$1 [L]

【讨论】:

  • 感谢您的回答,但没有奏效。我想可能是因为我的 htaccess 文件中的其他重写。该项目在 Magento 中,htaccess 有这样一行 RewriteRule .* index.php [L] 我尝试了你在该行之前和之后建议的重写。
  • 抱歉,我没有看到您的基本网址在 interview 文件夹中。请查看我的编辑并尝试将此代码放在 Magento 内部调度程序 RewriteRule .* index.php [L] 之前。
  • 还是不行。我在代码的最后一行不使用[L] 进行了尝试,否则整个网站都会崩溃。
猜你喜欢
  • 1970-01-01
  • 2016-02-25
  • 1970-01-01
  • 2012-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多