Mobile app version of vmapp.org
Login or Join

Login to follow query

More posts by @Megan663

3 Comments

Sorted by latest first Latest Oldest Best

 

@Ravi8258870

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?page=[CO] [PT]


As mentioned by Michele, you'll need Apache to do this with mod_rewrite. The above will send all page requests to index.php?page=[somepage], unless the file or directory exists (for things like images).

But you may also want to something more specific so all requests don't get sent to index. You would do something like:

RewriteEngine On
RewriteRule /page1 index.php?page=page1 [L]
RewriteRule /page2 index.php?page=page2 [L]


Although this can get messy if you have a lot of pages, so then you might want something like:

RewriteEngine On
RewriteRule /([a-z0-9_]+) index.php?page= [L]


This will only send all the requests that match the regular expression ([a-z0-9_]+) to index. This would be things like page1, page2, but not section/page1.

10% popularity Vote Up Vote Down


 

@Fox8124981

RewriteEngine on
RewriteRule ^somepage/([^/.]+)/?$ index.php?somepage= [L]


open up .htacess and put that code in there.

read more here www.workingwith.me.uk/articles/scripting/mod_rewrite

10% popularity Vote Up Vote Down


 

@Heady270

You'll need a webserver module to do this. If you are running Apache, for example, you can use mod_rewrite to accomplish these type of URLs.

For the .htaccess file you need basic knowledge of regular expressions.

A good start: www.modrewrite.com/

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme