url rewrite using htaccess to force load index.php - wordpress

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.

Related

how to add timthumb rewrite after theme set up

here is my htaccess rewrite rule for my theme's timthumb script.
RewriteRule ^pics/([0-9]+)x([0-9]+)x([0-9]+)x([0-9]+)/(.*)$ wp-content/themes/mt_movie/crop.php?src=$5&h=$1&w=$2&q=$3&zc=$4 [L]
I found a text about rewrite rules, on wp codes docs pages.
But i don't know what should i do / or how can i use my RewriteRule via this functions.
Here is the doc link : http://codex.wordpress.org/Rewrite_API/add_rewrite_rule
Actually i want to add this rule after when my theme activated on my customer's web site?
Could anyone help me about this.
Thanks.
This is an Apache rewrite rule. It should go in the .htaccess file in the wordpress directory on your server, assuming that your web server is apache.

Removing Wordpress directory name from certain URLs using .htaccess

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.

Static PHP application directory on a wordpress site

I'm having trouble setting up a directory with php files on a wordpress site.
I understand how to use templates to include a custom php file, but what I'm trying to do is access a php file as if wordpress was not installed. Right now when I create a new directory(dir1) and put an index.php file in that folder, then try to view by going to www.test.com/dir1 it shows a bulleted list with links to header, background, and updates with a text input for searching the website at the bottom.
I'm not sure if this is something that needs to be configure in my cPanel or if its a wordpress setting, or even if its an htaccess issue.
Please help me figure out what I need to do, or even at the very least, help me put into words what I'm trying to do. Thanks!
Usually Wordpress installed in the root has no impact at all on whatever is put into non-wp directories. Can you paste your .htaccess file from the root folder? And does your /dir1/ have any .htaccess?
Wordpress has nothing do to with existing folders/files. Here are some steps you may try.
Make sure your /dir1 doesn't have .htaccess or if in case you have and you need it to have it there, continue doing next steps.
Add some inclusions in rewrite engine of your .htaccess file. You may add something like this:
RewriteCond %{REQUEST_FILENAME} !-d and/or RewriteCond %{REQUEST_FILENAME} !-d
or
RewriteCond %{HTTP_HOST} !dir1
I hope this helps.
Bah, I've figured it out.
anytime I would FTP files onto my server, it would make the owner/group "root"
After I used WinSCP to change my users to match each website, it worked perfectly.
cPanel is a pain.

Installing Wordpress along side Cakephp

I have cakephp installed in the root directory. site.com/
i want to install wordpress blog at site.com/blog
but since cakephp will redirect all urls i am not sure how to do it ?
From: http://dogmatic69.com/blog/development/7-using-other-apps-with-cakephp-htaccess-config
One thing that is asked quite a lot on #cakephp is how to use other apps alongside CakePHP, and the answer giving is normally pretty ugly. Stick the files/folders in side webroot/. Although that does work, its not very nice. So ill show you a little trick with .htaccess files.
The first (really simple way) is to use a .htaccess inside the sub folder. For example you can have a copy of Joomla! running alongside cake with no issues when you have the .htaccess for Joomla! enabled. If the app does not have one and/or you would not know what to put in the .htaccess file you have another option
Make Apache stop processing rewrites if it finds a request for your sub directory. This is done by adding a rule for the sub directory and then telling Apache it is the last rule to process. The .htaccess file you want to edit is the one found inside your APP directory. All you want to add is the following line:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (some_folder/.*) $1 [L] # adjust the regex to what you want.
# normal cake rules
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
You can do this for as many sub folders as you wish, by changing the regex accordingly. Its pretty simple to do and a much cleaner way than having all your stuff inside the webroot/ folder of your APP.
Simply put the wordpress install into a "blog" folder in your /app/webroot folder.
Cake will load from the webroot as if the files were in a normal subfolder under a non-cake appliation. You may need to edit / adjust paths in the wp configs or .htaccess files throughout to get everything perfect but it isn't that difficult.
One way to do this is to have your domain pointing to site.com/cakefolder and then have another subdomain blog.site.com pointing to site.com/blog folder
This way to your user, it would always be site.com and blog.site.com

.htaccess - Rewrite a request to one directory before the request is handled by that directory?

I'm trying to exclude all BUT one directory from a rewrite rule. I want the request to be handled by the index.php file in the root directory which will then include the subdirectory's index.php file as part of a script after wrapping it with it's own code.
This is a really strange problem, since I'm trying to wrap Drupal within a Wordpress installation so that the existing site structure can stay put, and I can use a custom template to wrap the drupal output in a slightly customized wordpress theme.
If anybody has any idea how I can do this, I would be very very thankful.
htaccess files seem like arcane arts. Nobody seems to really get them that well, and I am no exception.
RewriteEngine on
RewriteCond $1 !^(drupal_directory|robots\.txt) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]
The ! will exclude drupal_directory and robots.txt etc...

Resources