Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I was wondering how to make my website's url look from:

some_folder/?d=some_file.php  

to..

/?d=some_file.php
share|improve this question

closed as off topic by enzotib, Jorge Castro, htorque, Takkat, jrg Feb 16 '12 at 1:51

Questions on Ask Ubuntu are expected to relate to Ubuntu within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

5  
Windows tags?... –  Uri Herrera Dec 9 '11 at 6:39
    
We will need more info about your set-up. Which web server are you using?. How is it configured?. Please edit the question and add as much information as possible. –  Javier Rivera Dec 9 '11 at 7:41
1  
This will most likely get a better answer over at superuser ( superuser.com ). - a sister site to this one. –  Portablejim Dec 9 '11 at 8:35
    
This is not really related to Ubuntu directly at all. –  RolandiXor Feb 16 '12 at 1:52

2 Answers 2

If you're using Apache, check out mod_rewrite.

share|improve this answer

If you are using the Apache web server, this is a guide for beginners.

Basically you'll need these entries in the .htaccess file in your website root directory:

RewriteEngine On
RewriteRule ^(.*)$ /some_folder/$1 [NC,L]

Also you should turn off rewrite in /some_folder/ otherwise multiple rewrites can occur. So you'll need another .htaccess file in /some_folder/ with:

RewriteEngine Off

The above will have the effect of reaching all files in /some_folder/ as they were in /. E.g.:

/index.html -> /some_folder/index.html

Notes:

  • mod_rewrite should be enabled to be able to rewrite URLs.
  • Make sure you do not create conflicts (e.g. identical file in both root and /some_folder/).
  • You need to allow FileInfo override for your website directory to be able to use .htaccess files.
  • Also using .htaccess files is a performance hit on web servers. See: Apache documentation how to avoid it.
share|improve this answer

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