LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > Apache Migration/Compatibility > URL Rewriting Help

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-03-2011, 03:07 PM
robfrew robfrew is offline
Senior Member
 
Join Date: Dec 2007
Location: Salt Lake City UT
Posts: 151
Question URL Rewriting Help

I need some help with some URL rewriting rules in .htaccess.

The current setup I have does not work correctly. Here it is:

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

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
# If the requested file or directory don't exist then redirect to the
# index.php and request the file. It will fetch it from the database
# or generate a "not found" message
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^swift/p$ /swift/p/
RewriteRule ^swift/p/$ /ext_forum.php
RewriteRule ^swift/p/([0-9]+)$ /swift/p/$1/
RewriteRule ^swift/p/([0-9]+)/$ /ext_forum.php?_p=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^swift/i$ /swift/i/
RewriteRule ^swift/i/$ /ext_post.php
RewriteRule ^swift/i/([0-9]+)$ /swift/i/$1/
RewriteRule ^swift/i/([0-9]+)/$ /ext_post.php?_i=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^swift/i/([0-9]+)/p$ /swift/i/$1/p/
RewriteRule ^swift/i/([0-9]+)/p/$ /ext_post.php?_i=$1
RewriteRule ^swift/i/([0-9]+)/p/([0-9]+)$ /swift/i/$1/p/$2/
RewriteRule ^swift/i/([0-9]+)/p/([0-9]+)/$ /ext_post.php?_i=$1&_p=$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^swift/(.+)/(.+)/([A-Z][A-Z])$ /swift/$1/$2/$3/ [NC, R]
RewriteRule ^swifts/(.+)/(.+)/([A-Z][A-Z])/$ /swift/city.php?id=$2&state=$3&st=$1 [NC, L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ u.php?u=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ u.php?u=$1
Essentially, what I need it to do is this. The first condition and rule redirects anyone who just types domain.com to www.domain.com.

Code:
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]
The 2 - 5 conditions and rules makes a php script search engine friendly.

And the last condition and rule allows usernames in URLS to be passed to a php script.

All of this works fine, except if I try to go to a real directory, it will not automatically pull up the index.php page. If I take away the url rewriting, it works again. For example, if I try to go to http://www.domain.com/mydir/, I get a page not found. However, if I go to http://www.domain.com/mydir/index.php, it works.

Any ideas?

Rob
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 12:11 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.