JA,
Oh, my, too many things to comment upon!

Originally Posted by
JATaylor
I am hoping for some help creating a .htaccess file / mod_rewrite rule to change the urls which are being displayed on a site which has just gone live.
The current .htaccess file contains:
Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sportsuk.org.uk/olympic-lessons/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sportsuk.org.uk/olympic-lessons/index.php [L]
</IfModule>
# END WordPress
1. NEVER include <IfModule> tests in an .htaccess file - it's extremely abusive of a server and SHOULD get you kicked off a shared server. In fact, this common noobie error is so prevalent, I have a Standard Rant for just this thing:
[rant #4]The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> ... </IfModule> wrapper is the same thing in the webmaster world. DON'T BE AN IDIOT! If you don't know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache's resources (and should NEVER be allowed on a shared server).
[/rant 4]
Don't take that personally, just learn to KNOW what the code you're using does and THINK about the effect of such code!
2. RewriteBase is designed to UNDO mod_alias redirections. WHERE are your mod_alias redirections? DELETE the RewriteBase directive and learn to tell mod_rewrite which directory you want it to operate on (whether by moving your .htaccess to the directory or including it in the regex in your DocumentRoot). [After reading more below, I should also tell you that you NEVER include your domain in a RewriteBase even when you're trying to UNDO a mod_alias Redirect.]
3. Passing through the index.php (to your DocumentRoot OR your /sportsuk.org.uk/olympic-lessons/ directory???) will only pass the DocumentRoot's index.php, not any of its supporting files (css, js, jpg, gif, etc).
4. A WordPress error, the . character in the RewriteRule's regex should be made optional so it will match a request made simply to the domain.
5. Appending a trailing / tells visitor browsers that they are one level deeper in to the directory structure of your website, i.e., all the relative links will go missing. Yes, this can be overcome by using absolute links or the <base> tag but it's just plain STUPID to force yourself to do that! Why in the world would you want to append trailing /'s?
6.
Unfortunately my knowledge of mod_rewrite / .htaccess is limited so i'm hoping someone can help me out!
Certainly: READ the sticky post for this forum which contains some of the tutorial Article linked in my signature. Otherwise, actually READ the tutorial as the members who have read it have comprehended mod_rewrite almost immediately.
6. DNS problems: Your website should be added as an addon domain (cPanel terminology) so that its DocumentRoot IS your olympic-whatever directory, not someone else's DocumentRoot. With Shared accounts being so inexpensive these days, there's no reason not to do this correctly.
7. NEVER get into a "stand-off" position with a host: Get a good host (even if that means $10 for a new domain name - or going through the registrar to get your domain pointed to the new host's DNS). Hosts are a dime-a-dozen so there's no need to put up with any BS from a disreputable host.
Regards,
DK
Bookmarks