[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

How do I do a mod rewrite to change the URL on a unix machine? I code in PHP which may not matter

Ideally I want:

http://www.abc.com/index.php?variable=5

to be:

http://www.abc.com/variable5.html

Second best would be:

http://www.abc.com/variable5.php

to:

http://www.abc.com/variable5.html

Thanks for any help...
0
smoothcat11
Asked:
smoothcat11
  • 2
4 Solutions
 
nizsmoDeveloperCommented:
http://www.webmasterworld.com/forum92/6079.htm

This shoud clarify things up :)
0
 
Mark GilbertSenior Performance EngineerCommented:
My favourite explanation of htaccess and dynamic ones is at:

http://corz.org/serv/tricks/htaccess2.php
0
 
SysTurnCommented:
Hi,

###############################
# Search engine friendly URLs #
###############################

RewriteEngine on

# Any request for variable5.html will be redirected to index.php?variable=5
# It will match only for numeric variables
RewriteRule ^variable(\d*)\.html$ index.php?variable=$1

# Any request for variable5.html will be redirected to variable5.php
RewriteRule ^variable5.html$ variable5.php

# Any request for any non existing .html page will be redirected to .php page
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ $1.php


Kind Regards
Bakr Alsharif
0
 
SysTurnCommented:
You can also the L flag to at the end of any rule to stop processing any rules after.
example:

RewriteRule ^variable(\d*)\.html$ index.php?variable=$1  [L]
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now