1

There is PHP file redirect to

header("location:./exchange?title=".$directionin. '_'. $directionto);

I want to re-write this URL localhost/moneyworld/exchange?title=BTC_PMUSD to this localhost/moneyworld/BTC_PMUSD i have tried

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /moneyworld/exchange?title=$1 [L]

and i put the .htaccess file in the root and it didn't work then i put it in moneyworld folder and also it didn't work.

RavinderSingh13
  • 101,958
  • 9
  • 41
  • 77

1 Answers1

2

Could you please try following(based on your shown samples), In case you are looking to rewrite/redirect from localhost/moneyworld/exchange?title=BTC_PMUSD to localhost/moneyworld/BTC_PMUSD URL then try following

RewriteEngine ON
RewriteCond %{THE_REQUEST} \s/(moneyworld)/exchange\?title=([^\s]*)\s [NC]
RewriteRule ^ /%1/%2 [NE,QSD,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ /moneyworld/exchange?title=$2 [L]  
Amit Verma
  • 38,175
  • 19
  • 80
  • 104
RavinderSingh13
  • 101,958
  • 9
  • 41
  • 77
  • @Amit Verma Hi i am thinking that if i want it without moneyworld folder like www.domain.com/exchange without /(moneyworld)/ Thanks – Mohamed Nabil Jan 12 '21 at 10:14
  • @MohamedNabil, Hi Nabil, you could open a new question for this along with your efforts and with clear requirements. Its not advised to edit or change requirements for old questions, cheers. – RavinderSingh13 Jan 12 '21 at 10:15
  • https://stackoverflow.com/questions/65682014/how-to-redirect-a-url-and-then-rewrite-it-to-same-url-with-htaccess-but-from-the – Mohamed Nabil Jan 12 '21 at 10:23