I am trying to redirect a URL using a .htaccess file. The URL structure is like:

http://mydomain.com/folder/.anything_goes_here

Note the dot in the above Url. I want to remove it somehow using .htaccess.

I have tried using RewriteRule but it's not working. Here is the code I used:

RewriteEngine on
RewriteBase /
RewriteRule ^/folder/.(.*+)/?$ /folder/$1 [L]

Any help would be highly appreciated. Thank you.

有帮助吗?

解决方案

The period has a special meaning in regular expressions (it means "any character"). In order to explicitly specify a period, you need to escape it.

RewriteRule ^/folder/\.(.*+)/?$ /folder/$1 [L]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top