0

So is this possible to redirect URL with all the parameters and file names too to another URL. For example, there is a URL like

example.com/anyfile.php?param1=data2

So is this possible to redirect this URL to

example2.com/anyfile.php?param1=data2

Without having the file anyfile.php Maybe something to do with .htaccess or anything?

Shiraz Ahmad
  • 85
  • 1
  • 1
  • 8
  • Yes. It is possible with `.htaccess`. Please refer the following link https://help.dreamhost.com/hc/en-us/articles/215747748-How-can-I-redirect-and-rewrite-my-URLs-with-an-htaccess-file- – Chilarai Jul 06 '20 at 10:40
  • Yeah, i see there, But it only allows to redirect to index.php or any other file without params and file name. – Shiraz Ahmad Jul 06 '20 at 15:10
  • You will need to add regular expressions in the syntax. Please check the document thoroughly. I am using my mobile so I may not be accurate. You are looking for the Query String Append flag -e.g `RewriteRule ^anyfile.php(.*)$ http://example2.com/anyfile.php?q=$1 [QSA]` – Chilarai Jul 06 '20 at 15:34
  • Does this answer your question? [.htaccess redirect all pages to new domain](https://stackoverflow.com/questions/1945568/htaccess-redirect-all-pages-to-new-domain) – glinda93 Jul 07 '20 at 02:38

0 Answers0