|
|
|
|
||||||
| alt.apache.configuration Apache web server configuration issues. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hey guys,
I'm busy with a project, but because I'm such a bitch about details I want to solve this. I want to add a trailing slash to the url if it is not present. for example: http://mydomain.com/products/books should be rewritten to: http://mydomain.com/products/books/ Currently I have a few rules in my .htaccess file: --- Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !^.*\.(gif|jpg|jpeg|png|js|css)$ [NC] RewriteRule ^(.*)$ index.php [L] --- But how would I go about checking if it ends with a slash? Greetz, Wizz |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
To elaborate on the current RewriteRules: I handle all the request
through a php script inside index.php. It does work now, I just think it looks better with the trailing slash... Greetz, Wizz On Jan 9, 2:27 pm, Wizz <woutaw...@gmail.com> wrote: > Hey guys, > > I'm busy with a project, but because I'm such a bitch about details I > want to solve this. > > I want to add a trailing slash to the url if it is not present. > > for example:http://mydomain.com/products/books > > should be rewritten to:http://mydomain.com/products/books/ > > Currently I have a few rules in my .htaccess file: > > --- > Options +FollowSymLinks > > RewriteEngine on > RewriteBase / > > RewriteCond %{REQUEST_FILENAME} !^.*\.(gif|jpg|jpeg|png|js|css)$ [NC] > RewriteRule ^(.*)$ index.php [L] > --- > > But how would I go about checking if it ends with a slash? > > Greetz, > > Wizz |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
"Wizz" <woutawizz@gmail.com> schreef in bericht news:34ac85d4-b91d-4ffa-a00c-1d90e0497fb7@21g2000hsj.googlegroups.com... >> On Jan 9, 2:27 pm, Wizz <woutaw...@gmail.com> wrote: >> Hey guys, >> >> I'm busy with a project, but because I'm such a bitch about details Yet another detail ... first quote than response is the usenet habbit >> Options +FollowSymLinks >> >> RewriteEngine on >> RewriteBase / >> >> RewriteCond %{REQUEST_FILENAME} !^.*\.(gif|jpg|jpeg|png|js|css)$ [NC] >> RewriteRule ^(.*)$ index.php [L] >> --- >> >> But how would I go about checking if it ends with a slash? In fact how to test for being both extentionless AND trailing-slashless: RewriteCond %{REQUEST_URI} !\.[^/]+$|/$ [NC] RewriteRule (.*) $1/ [R,QSA] RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|js|css)$ [NC] RewriteRule . index.php [L] > To elaborate on the current RewriteRules: I handle all the request > through a php script inside index.php. It does work now, I just think > it looks better with the trailing slash... If details do bother you rather have your script(s) and template(s) generate the slash than make a browser ask twice. HansH |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
"Wizz" <woutawizz@gmail.com> wrote in message
news:34ac85d4-b91d-4ffa-a00c-1d90e0497fb7@21g2000hsj.googlegroups.com... > On Jan 9, 2:27 pm, Wizz <woutaw...@gmail.com> wrote: >> Hey guys, >> >> I'm busy with a project, but because I'm such a bitch about details I >> want to solve this. >> >> I want to add a trailing slash to the url if it is not present. >> >> for example:http://mydomain.com/products/books >> >> should be rewritten to:http://mydomain.com/products/books/ >> <SNIP> > To elaborate on the current RewriteRules: I handle all the request > through a php script inside index.php. It does work now, I just think > it looks better with the trailing slash... > You could do this in your php script with something like: if (<no slash on the end>) { Header("Location: http://mydomain.com/products/books/"); die; } |
|
![]() |
| Outils de la discussion | |
|
|