简体   繁体   中英

url rewrite using htaccess to force load index.php

I'm trying to make a user-friendly author page url for my wp site. Currently what I have done is I have created a folder by name author under my root theme folder and I have put my author page mark-up file( index.php ) inside this folder.

I also have a plugin ' Easy url rewrite ' which I'm using to make www.sitename.com/author request to load <theme dir>/author/index.php file. And it is working fine.

Now I want any www.sitename.com/author/<anyname> also to load my index.php file.

Can I achieve this using .htaccess rules? Does .htaccess rule conflict with my url-rewrite plugin?(which one will be executed first?) Can I achieve this whole thing using only .htaccess rules(ie., without the use of plugin rewrite) If so, What rules do I need to write in .htaccess file?

Thanks! Greatly appreciate your help.

Does .htaccess rule conflict with my url-rewrite plugin

yes, probably.

which one will be executed first?

The htaccess rules get executed first, but that's part of how wordpress works. There are rules that essentially send everything to wordpress' controller and then wordpress handles it from there.

Can I achieve this whole thing using only .htaccess rules

It depends. Is your page generated by wordpress or is it just a page by itself separate from wordpress? If it's the former, you're going to need to work on some more easy url rewrite rules, if the author page is separate from wordpress then you can do this entirely with htaccess.

If that's the case, I'd guess the rules would look something like:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^author/(.*)$ /themedir/author/index.php [L]

Those rules need to be before any wordpress rules that you have in the htaccess file in your document root.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM