Status
Not open for further replies.

ziycon

New Member
Is this how the code is written in the .htaccess file or how to you seperate two rules?
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^clubs/([a-zA-Z0-9_]+)$ v/cl_desc.php?id=$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^clubs-dublin/([a-zA-Z0-9_]+)$ v/cl_desc_vote.php?id=$2
 

mneylon

Administrator
Staff member
You shouldn't have to repeat the REQUEST line
 

ziycon

New Member
You shouldn't have to repeat the REQUEST line

So i just do it like this and have as many rules as i want!?
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^clubs/([a-zA-Z0-9_]+)$ v/cl_desc.php?id=$1
RewriteRule ^clubs-dublin/([a-zA-Z0-9_]+)$ v/cl_desc_vote.php?id=$2
 

mneylon

Administrator
Staff member
Pretty much :)

If you look at this one from a wordpress blog:

Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

In that example all processing is done within wordpress

Or for Irishblogs.com:

Code:
<IfModule mod_rewrite.c>
   RewriteEngine On

   ## Details Link Page Rewrite##
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule (.*)detail/link-(.*).htm[l]?$ detail.php [QSA,NC]

   ## Pagination Rewrite
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule (.*)page-(\d+)\.htm[l]?(.*)$  $1/?p=$2 [PT,NC]

   ## Category redirect
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-l
   RewriteRule ^(.*)$ index.php [QSA,L]

</IfModule>

They've actually repeated it ....

In either case if you have access to your httpd.conf you can turn on mod_rewrite logging to see what is working (or not as the case maybe)
 

ziycon

New Member
Nice one, i just cant seem to get it working! the first rule is working fine but the second one keeps bringing me to an error page saying that that page im looking for doesnt exist! :mad:

Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^clubs/([a-zA-Z0-9_]+)$ v/cl_desc.php?id=$1
RewriteRule ^clubs-dublin/([a-zA-Z0-9_]+)$ v/cl_desc_vote.php?id=$2

It says for the second like that the url is clubs/clubs-dublin/1 is it ment to take the first rule and add it in like that!?
 

daviddoran

New Member
Code:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^clubs/([a-zA-Z0-9_]+)$ v/cl_desc.php?id=$1
RewriteRule ^clubs-dublin/([a-zA-Z0-9_]+)$ v/cl_desc_vote.php?id=$1
The second Rule should have $1, not $2 as I have changed.

Also, Apache doesn not cascade the rules (add them), as soon as one matches it will redirect.
 

ziycon

New Member
Anyone know how to setup mod_rewrite on a local enviroment, there is no .HTAcess file, on the htdocs apache folder!?
 

mneylon

Administrator
Staff member
Two options:

1 - in the apache vhost config of the test site
2 - in a .htaccess file
 

mneylon

Administrator
Staff member
I don't know how you've configured your setup, but I would presume that the web root for the site is in htdocs/wesbite/ , so you should put it in there ie. it has to be part of the actual site
 

ziycon

New Member
Keep getting this error:

Not Found The requested URL /dn/clubs/34 was not found on this server.

This what i have in the .htaccess file:
Code:
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^clubs/([a-zA-Z0-9_]+)$ v/cl_desc.php?id=$1
RewriteRule ^clubs-dublin/([a-zA-Z0-9_]+)$ v/cl_desc_vote.php?id=$1
 

markowe

New Member
Keep getting this error:

Not Found The requested URL /dn/clubs/34 was not found on this server.

Are you sure your hosting service fully supports .htaccess? Stupid question, but not all of them do, and you can get errors like that for that reason.

That's one of the reasons why I moved from Netfirms...
 

daviddoran

New Member
AFAIK if mod_rewrite was not available then you would get a 500 Error so that is ok.
More Obvious Questions:
1) Is the .htaccess script in the dn directory?
2) Is v/cl_desc_* relative to the .htaccess file?
 

markowe

New Member
AFAIK if mod_rewrite was not available then you would get a 500 Error so that is ok.

Not necessarily - on Netfirms hosting, the .htaccess seems to work, but the rewrites don't work, and just direct you back to index.php. No 500 errors... Just a suggestion, because it has been the cause of many a frustration with .htaccess (and a good reason to change provider in my book).
 

ziycon

New Member
AFAIK if mod_rewrite was not available then you would get a 500 Error so that is ok.
More Obvious Questions:
1) Is the .htaccess script in the dn directory?
2) Is v/cl_desc_* relative to the .htaccess file?

1) yes
2) yes

markowe said:
Are you sure your hosting service fully supports .htaccess? Stupid question, but not all of them do, and you can get errors like that for that reason.

That's one of the reasons why I moved from Netfirms...
Its on a localhost, its a test machine at home!
 
Status
Not open for further replies.
Top