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.

In my website I'm trying to implement friendly URLs. I have an index.php file and a .htaccess file in my hosting's public folder. I'm using the following code in the .htaccess file:

DirectoryIndex index.php
RewriteEngine On
RewriteRule ^article/([0-9]+)/$ ../Feed/Article.php?id=$1

Therefore, if anyone enters www.example.com/article/15/, it loads the Article.php passing the 15 value through GET.

But the problem is that the Article.php file is outside the public folder (hence the ../) and Apache doesn't find it.

Can anyone help me?

Note: I don't have access to the httpd.conf file.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

That doesn't rewrite to a filesystem path but a URI. so if Article.php is at http://example.com/Article.php your rewrite rule would look like:

RewriteRule ^article/([0-9]+)/$ http://example.com/Article.php?id=$1
share|improve this answer
    
Probably better off stripping the http://example.com out of that rewrite. –  Ladadadada Mar 15 '12 at 23:56
    
Oh, ok I understand. But that forces me to save all the files inside the public folder, right? Isn't it that very insecure? –  fedeetz Mar 16 '12 at 2:45
    
You can put it in another subdirectory and forbid access to it. But I don't see why it should be a security issue if users can access the script directly? –  Marian Mar 16 '12 at 17:01
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.