Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This is my first attemp at creating clean URLs using a .htaccess file.

My page is a simple, php generated page.

My page is http://www.dimiourgiasite.gr

On the top left corner of the page I have a link, pointing to http://www.dimiourgiasite.gr/arxiki

To redirect I use this .htaccess file:

RewriteEngine On
RewriteRule ^arxiki$ index.php
RewriteRule ^arxiki/$ index.php

It is my understanding that weather I go to dimiourgiasite.gr/arxiki or dimiourgiasite.gr/arxiki/ I should be getting the same page. That is not the case.

Any explanations / things I am doing wrong?

Sorry I am not posting links and making you type the address, but since my rep is only 3, the site limits my amount of hyperlinks per post to 2.

share|improve this question
2  
What do you get instead of the same page? –  Shane Madden Jan 27 '12 at 5:16
add comment

1 Answer 1

up vote 2 down vote accepted

The rewrite and the page are both working fine. The problem is that with a trailing slash, your browser tries to grab the stylesheet from /arxiki/views/style.css which doesn't exist. Without the trailing slash, the stylesheet comes from /views/style.css.

If you change your stylesheet link in your source code to /views/style.css instead of views/style.css, the styles will be applied correctly.

You could probably have identified this from your Apache error logs as you would have seen a lot of "File not found" errors complaining about /arxiki/views/style.css.

You can also combine both your rewrite rules into one like this:

RewriteRule ^arxiki/?$ index.php

The question mark means "0 or 1 of the preceding character".

share|improve this answer
    
It is my understanding there are a number of different regex evaluations, depending on programming language. Which one does apache use in the .htaccess file? –  AnPel Jan 27 '12 at 12:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.