Go Premium for a chance to win a PS4. Enter to Win

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

PHP mod rewrite query

Hello,

How would I use mod_rewrite to redirect users from a URL as follows:

www.domain.com/folder1/index.php?contact-us

to convert this URL on the server to actually go to:

www.domain.com/index.php?contact-us

So take a URL, strip out a subfolder that appears in all queries from 1 domain name and leave the rest of the URL intact.  The bits after the index.php change so its important to take the received URL and adjust it then keep the remainder.  e.g. index.php?home and index.php?who are we  etc.

Thanks in advance
0
cloughs
Asked:
cloughs
1 Solution
 
Julian HansenCommented:
Try this

RewriteRule ^(.*)/index.php$ index.php [L,Q,NC]

Open in new window

0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

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