English 中文(简体)
背 景
原标题:.htaccess issue with redirecting folder
  • 时间:2011-11-18 07:34:55
  •  标签:
  • .htaccess

I have a folder named /test in my application.

Right now i am trying to write an .htaccess file that would show all requests to /test* as /test.

例如:

www.example.com/test/ 是实际与index的直系。 页: 1

All the requests like the following should go to the same /test directory

www.example.com/test-hello/
www.example.com/test-world/
www.example.com/test-htacess/
www.example.com/test123/

Basically any requests to /test* should go to /test.

This is what I ve tried so far:

RewriteRule ^/test* /test
最佳回答

您需要使用<代码>RewriteCond,先与“url”测试相匹配。

如下:

RewriteCond %{THE_REQUEST} ^GET /test/
RewriteRule ^test/(.*) /test/$1 [L,R=301]
问题回答

你的经常表达是错误的。 页: 1 你的统治将相当于/试验。

星号表示,其前面的果园可以包括零或更多时间。 狗是一种特别的果园,这意味着这里可能有任何东西。 <代码>*对包括空洞在内的每一条插座进行对应。 另见

您目前没有将<代码>-hello、-world等置于您的背后。 是什么? 档案吗? 还是这样?

改写规则的第二部分应为档案。 类似于

Rewrite Rule ^/test(*)$ /test/$1.php

职能优先:

/testABC to /test/ABC.php

但我不理解你想要完成什么?





相关问题
Ignore symlinks in clean URL s in .htaccess

Example URL: example.com/user /user is both a symlinked directory and a valid URL to content on my site. I user Horde Routes to request the content and all requests to the site go through index.php. ...

.htaccess File Options -Indexes on Subdirectories

I have the following .htaccess line, simple no indexes on root. Options -Indexes What do we add so it propagates to any sub directory instead of having to create one file for each? One .htaccess on ...

Mod Rewrite ignoring -d

After a day or two, I am still fighting with Mod Rewrite. It seems that 60% of my development time is spent battling the server. My current URL structure is such that all http://example.com/xyz and ...

ErrorDocument 404 Not Sending Referrer Information: PHP

I m using a standard htaccess ErrorDocument 404 to redirect users to a new page. In order to customize the 404, I need to know their referrer information (from the page they Tried to visit). $...

Find all htaccess files on server [closed]

I m looking for a Linux command to go through all the directories on my server and find all .htaccess files. The output would be a list of all those files with full path, creation/modification date ...

301 Redirect Help with Dynamic URL s and Multiple Id s

I just did a redesign for www.wildchildclothes.com which has a new URL structure. The old site ran on Zen Cart and had a bad URL structure. Here are some examples of what I want to redirect from: OLD:...

热门标签