A few issues ...

New to mod_rewrite? This is a good place to start.

A few issues ...

Postby xerosis » Mon Jun 29, 2009 2:46 am

Hi Guys,

I have a website called: http://www.titrha.com

basically I am having some problems making things work with mod_rewrite; here are some of the things I need:

======= 1 ========
http://www.titrha.com/index.php?page=info&slug=about
to become
http://www.titrha.com/info/about/

I have written this code:
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?page=$1&slug=$2 [QSA,L]
but it wont show properly.

======= 2 ========
http://www.titrha.com/index.php?page=po ... =something
to become
http://www.titrha.com/something/


======= 3 ========
http://www.titrha.com/index.php?page=my ... me=someone
to become
http://www.titrha.com/user/someone/


======= 4 ========
http://www.titrha.com/index.php?page=ho ... g=question
to become
http://www.titrha.com/alpha/question/


basically in all cases its the slug that is random, the rest are the same. Thanks a lot!
xerosis
 
Posts: 14
Joined: Fri Sep 19, 2008 2:46 am

Postby xerosis » Mon Jun 29, 2009 2:48 am

I actually noticed one thing, in this case do I have to change my folders from for example:

css/styles.css
to
../../css/styles.css

?
xerosis
 
Posts: 14
Joined: Fri Sep 19, 2008 2:46 am

Postby richardk » Mon Jun 29, 2009 11:29 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^alpha/([^/]+)/?$ /index.php?page=home&searchtype=alpha&slug=$1 [QSA,L]
RewriteRule ^user/([^/]+)/?$  /index.php?page=mypage&uname=$1               [QSA,L]

RewriteRule ^([^/]+)/([^/]+)/?$ /index.php?page=$1&slug=$2 [QSA,L]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php?page=posts&slug=$1 [QSA,L]


I actually noticed one thing, in this case do I have to change my folders from for example:

css/styles.css
to
../../css/styles.css

?

FAQ: Relative paths to images, JavaScript, CSS and other external/linked files are broken.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 101 guests

cron