-3

我想编写一个 htaccess 文件,该文件采用输入链接并将它们转换为输出(这基本上是 /test/ 之后的任何内容并添加 ?location=

输入

  1. http://test.co.uk/test/uk/england/london
  2. http://test.co.uk/test/uk/england
  3. http://test.co.uk/test/uk/england/london/soho

至:(输出)

  1. http://test.co.uk/test/?location=uk/england/london
  2. http://test.co.uk/test/?location=uk/england
  3. http://test.co.uk/test/?location=uk/england/london/soho
4

1 回答 1

2

测试目录的 htaccess 文件中,添加:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ?location=$1 [L]

或者在文档根目录的 htaccess 文件中:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^test/(.*)$ /test/?location=$1 [L]
于 2013-04-23T17:41:02.253 回答