1

I have a WP site, all working great. I then have a stand alone landing page called "landing-page.php" and this is in the root directory.

I need to remove the .php and the trailing slash in order for the page to load. I only want to remove the trailing slash for this specific page. I cannot change the directory where this page is saved as I have ad campaigns that have been configured with /landing-page/ so I cannot go change these without re-approval etc

I have the following code which kinda works BUT... I cannot access /wp-admin.

So I need the rules only to apply to this landing page:

RewriteEngine On
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^landing-page$ landing-page.php [L]


# 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

Please help... thanks

4

2 回答 2

0

你的意思是摆脱这条线:

RewriteRule ^(.*)/$ /$1 [L,R=301]

并将下一行更改为:

RewriteRule ^landing-page/?$ landing-page.php [L]

?

不确定问题出在哪里,但第一行可能是问题所在,因为它用斜杠匹配所有内容。但是,如果您想规范化尾部斜杠,只需使其匹配landing-page

RewriteRule ^landing-page/$ /landing-page [L,R=301]
于 2013-11-12T19:31:42.687 回答
0

将您的前 2 条规则替换为:

RewriteRule ^(landing-page)/$ /$1 [NC,L,R=301]
RewriteRule ^landing-page$ landing-page.php [L,NC]
于 2013-11-12T19:31:49.833 回答