質問

So I have one Wordpress install in a sub-directory. (www.mysite.com/wp/)

What I need is for certain pages to remove the WP directory name from the URL.

so 'www.mysite.com/wp/careers' needs to be -> 'www.mysite.com/careers'

I have an .htaccess in the root directory and in the wp directory. I've gotten some of my rules to work when permalinks are disabled in WP, but when those are enabled (which they need to be) the WP .htaccess overrides any rules I have in the root.

Is there any way to have 2 htaccess co-exist in this manner? Sorry I haven't messed with wordpress and apache very much.

Any input is greatly appreciated.

**So I finally got this working, it was just a matter of like you said formatting redirect URL so wordpress likes it.

So in my root htaccess file : for this url mysite.com/careers

RewriteRule ^careers/?$ wp/index.php?pagename=careers [L]

And voila and it started working just fine.

役に立ちましたか?

解決

Yes, you can have rules in both htaccess files but it's going to be tricky as wordpress has specific ways that it will expect URLs to look.

In the wordpress htaccess file, above any wordpress related rules, add:

RewriteCond %{THE_REQUEST} \ /+wp/careers
RewriteRule ^ /careers [L,R]

then in the htaccess file in the document root add:

RewriteRule ^careers$ /wp/careers [L]

But again, depending on what wordpress expects the "careers" URL to look like, this may not solve your problem.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top