从网址中删除字符串

时间:2015-02-11 16:28:01

标签: regex apache .htaccess mod-rewrite

我是regexmod-rewrite的新手,我正试图解决这条道路:

http://127.0.0.1/projects/wp-deal/media/resizer/710x475/r/127.0.0.1/projects/wp-deal/wp-content/uploads/2014/12/photo.png 

所以它变成了:

http://127.0.0.1/projects/wp-deal/wp-content/uploads/2014/12/photo.png

这是我到目前为止所尝试的内容:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /projects/wp-deal/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /projects/wp-deal/index.php [L] 
</IfModule>

1 个答案:

答案 0 :(得分:0)

您的文档根目录中的htaccess文件中,尝试添加:

RewriteEngine On
RewriteRule ^projects/wp-deal/media/resizer/[^/]+/r/[^/]+/(projects/wp-deal.*)$ /$1 [L]