htaccess mod_rewrite (seemed-simple redirects)

Discussions about Apache mod Rewrite, .htaccess, Use, experiences ... URL Rewriting.

Moderator: Moderators

htaccess mod_rewrite (seemed-simple redirects)

Postby kristynilsson » Fri Mar 02, 2007 4:29 pm

Good morning, and much thanks. 2 issues: seemingly minor, but I'm drowning in htaccess mod_rewrite. Mea culpa: I am a ballet choreographer with a growingly popular and huge set of dance quotes on a page I named before I understood the importance of naming protocols.

Site: http://2nilssons.com Server: Apache 1.3.37 (Unix) Host: midphase

1. Exclude www redirect: optimized search engine results (have registered as such w/Google, but for other engines need redirect in htaccess)
FROM -http://www.2nilssons.com
TO -http://2nilssons.com

2. Path/file rename redirect: corrections for crappy, capitalized, too-long titling disease to exclude unnessary sub-dirs and title gaps that result in %20. Most critical example:
FROM -http://2nilssons.com/Dance/Dance Quotes.htm
ALSO AS -http://2nilssons.com/Dance/Dance%20Quotes.htm
(the above two paths are no longer working, as I thought my .htaccess redirects would work, and I've already done the site mods... hence the urgency)
TO -http://2nilssons.com/dancequotes.htm

Attempted .htaccess redirects to no avail; neither redirect is working.

Here is the original .htaccess code - website and uploads function:[/code]
Code: Select all
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

order deny,allow
deny from all
allow from all

order deny,allow
deny from all

AuthName 2nilssons
AuthUserFile /home/nilsson/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/nilsson/public_html/_vti_pvt/service.grp



A. This is my attempt at the exclude www redirect:
Code: Select all
RewriteEngine ON
RewriteRule ^/Dance/Dance%20Quotes.htm$ http://2nilssons.com/dancequotes.htm$1 [L,R=permanent]


B. These are my attempts at the redirect to simpler path names:
Code: Select all
RewriteEngine ON
RewriteRule ^/Dance/Dance%20Quotes.htm$ http://2nilssons.com/dancequotes.htm$1 [L,R=permanent]


Also, w/o the "/" afer "^" and before first "Dance" in first path:
Code: Select all
RewriteEngine ON
RewriteRule ^Dance/Dance%20Quotes.htm$ http://2nilssons.com/dancequotes.htm$1 [L,R=permanent]


The rewrites don't accomplish the redirects. Further: if installed below existing, working .htaccess code - site works, but uploads don't work; and, if installed after the "IndexIgnore" statement and before the "order deny,allow" statement, the site stops working immediately.

Any help and guidance with this will be enormously appreciated!

Much thanks to anyone that can help!


Kristy Nilsson / Atlanta
kristynilsson
 
Posts: 2
Joined: Fri Mar 02, 2007 3:24 pm

Advertisement

Initial Challenges Solved - Smaller New Ones

Postby kristynilsson » Sat Mar 03, 2007 1:32 am

INITIAL PROBLEMS SOLVED (code solution below) -
ONE SMALL NEW PROBLEM, and two small additional questions.

Last Issues:

1) We discovered that with the addition of the new .htaccess file code, we can't access the server for updating the website. IE: to do updates, we have to strip out the added code from .htaccess, do the update, then reinstall the new code in .htaccess again. Any thoughts, anyone?

2) How many Redirect statements can one safely enter in the .htaccess file?
We may need to apply this solution to a few more files; does anyone know if there is a practical or absolute limit?

And, should we add an [L] at the end of the last statement, or any of other code (Permanent, etc.)


Here's the code that solved the two issues (see original post for the pre-existing .htaccess code):


Code: Select all
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

order deny,allow
deny from all
allow from all

order deny,allow
deny from all

AuthName [url]www.2nilssons.com[/url]
AuthUserFile /home/nilsson/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/nilsson/public_html/_vti_pvt/service.grp

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^2nilssons\.com [NC]
RewriteRule (.*) http://2nilssons.com/$1 [R=301,L]

Redirect 301 "/Dance/Dance Quotes.htm" [url]http://2nilssons.com/dancequotes.htm[/url]



Thank you to everyone for your think-time and attention on this.

Any thoughts on the additional questions/problems will be greatly appreciated.


Kristy (and Scott) Nilsson
kristynilsson
 
Posts: 2
Joined: Fri Mar 02, 2007 3:24 pm

Postby dcz » Sat Mar 03, 2007 2:00 pm

And welcome :D

I assume you are not really using this one :

Code: Select all
Redirect 301 "/Dance/Dance Quotes.htm" [url]http://2nilssons.com/dancequotes.htm[/url]


but rather :

Code: Select all
Redirect 301 "/Dance/Dance Quotes.htm" http://2nilssons.com/dancequotes.htm


Then about the maximum number of line we can add in a .htaccess file it depends on your server, but you should be able to go up to few hundreds without problems.
The most ressources consuming lines are the rewriterules, so the order matters as well as the proper use of the L flag.
The L flag will prevent any more mod_rewrite work after the first rewriterule will have matched.

Obviously, your .htaccess is as is far from being heavy.

Then, about you other problem, how do you update ? FTP ? or HTTP ?

And, what is this part for :

Code: Select all
order deny,allow
deny from all
allow from all

order deny,allow
deny from all

AuthName 2nilssons
AuthUserFile /home/nilsson/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/nilsson/public_html/_vti_pvt/service.grp


Again some [url] bbcode I assume you do not use for real ;)
Obviously, you're using some auth script, but do you need it here ?

If you are using some protected folders, you could only run the auth part within the particular folder's .htaccess. It could be this to cause trouble here.

++
Useful links :
SEO Forum || SEO Directory || SEO phpBB || Search
____________________

Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Recherche
dcz
Admin
Admin
 
Posts: 21219
Joined: Fri Apr 28, 2006 9:03 pm


Return to Apache mod Rewrite

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 1 guest