Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trailing Slash 1

Status
Not open for further replies.

infoxicated

Technical User
Nov 24, 2000
3
0
0
GB
Hi - sorry if this has been answered before - I tried searching for tips but came up blank.

My question is this: How do I set up Apache so that the trailing slash on url's is not required?

I'm building an intranet site and decided on Apache, which seems to have been a great choice so far (for someone who was new to setting up servers, anyway!). I have the intranet site in a directory of htdocs called "foo" - so to access it I either type my machine's IP then /foo/ or I type localhost/foo/.

Is it possible to set it up so that I could just type localhost/foo without the server returning an error?

Any help would be most gratefully received.

Cheers,

Rob Foxx :O)
 
I'd the same prob... after a long time of searching and reading i wrote this:
Code:
# mod_rewrite configuration for trailing-slash 
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([/A-Za-z0-9_]*)?([A-Za-z0-9_]+)$
RewriteRule ^(.*) [URL unfurl="true"]http://%{SERVER_NAME}$1/[/URL] [R]
[code]

Don't know if it could be done better, but it works ;)
 
Thanks for that, I'll give it a try!

A:T:B: inFoxicated
 
Hi,

We have been having the same problem, and have used the example code (

#mod_rewrite configuration for trailing-slash
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([/A-Za-z0-9_]*)?([A-Za-z0-9_]+)$
RewriteRule ^(.*) [R]

)
in the hppd.conf file. we have also tried a different, but very silimiar example and that didn't work either.

Does anyone have any ideas what else it could be?

We are running a number of virtual hosts, one of which has a number of sites running as subfolders from within it. i.e.,

-

they only come up if you have the trailing slash.

any ideas??!

thanks

Lewis
 
I've had the same problem and was wondering does it matter where in httpd.conf I stick

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([/A-Za-z0-9_]*)?([A-Za-z0-9_]+)$
RewriteRule ^(.*) [R]

??

DazFG
 
Yes, the rewrite module has to be loaded before those lines. //Daniel
 
I just put

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/([/A-Za-z0-9_]*)?([A-Za-z0-9_]+)$
RewriteRule ^(.*) [R]

at the end of my httpd.conf file and it doesnt work... For the modules, I have:

LoadModules rewrite_modules
AddModule mod_rewrite.c

I put the Rewrite code after the modules, is there something that I am doing wrong?
 
oh, something that I should add, when I try to start Apache with the rewrite code in, I get this error message:

RewriteBase: only valid in per-directory config files

What does that mean?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top