-1

I am trying to create a .htaccess file that changes

this url : http://www.mysite.co.uk/~username/directory1/directory2/directory3/?format=xml

to this: http://www.mysite.co.uk/~username/directory1/director2y/directory3/xml

for example you will enter the second url into the browser but the browser will process it like the first url.

I have researched .htaccess files and Rewrite rules and conditions and to be honest find it quite confusing.

The code I currently have tried using to do this is:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^format=([A-Za-z0-9-]+)$
RewriteRule ^directory3/index.php http://www.mysite.co.uk/~username/directory1/directory2/directory3/%1  

Any help will be greatly appreciated

1 Answers1

0

Try:

RewriteCond %{THE_REQUEST} \ /+directory3/index\.php\?format=([A-Za-z0-9-]+)$
RewriteRule ^ /~username/directory1/directory2/directory3/%1 [L,R=301]

then to rewrite it back

RewriteRule directory3/(.+)$ directory3/index.php?format=$1 [L]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220