0

I'm new to htaccess and I need some help with a rewrite rule.

I wish to rewrite:

/all-accomodation/anything/ to: /portfolio-gallery/anything/

The 'anything' could be any slug.

One thing to note is that I have a page with a slug of 'all-accomodation' and when requested by itself shouldn't rewrite.

Here is my current htaccess file:

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

Thanks in advance,

Dave

4

1 回答 1

2

您不想编辑 Wordpress 的重写。在该块之上,您可以尝试:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^all-accomodation/(.+)(/?) /portfolio-gallery/$1$2 [L]
</IfModule>

这将 301 重定向所有请求。

于 2013-06-27T19:47:49.770 回答