logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Help on Removing Query String from the URL
Author
jponnusamy



Joined: 30 May 2016
Posts: 12
Location: Qatar, Doha

PostPosted: Mon 06 Jun '16 8:24    Post subject: Help on Removing Query String from the URL Reply with quote

Dear All,
We want to hide Query Strings from given URL for End User. I tried with below RewriteRule. URL is getting Change but getting 404 Error.
Current URL:
http://cmspweb1.com/sites/pressrel?year=2016&month=5
http://cmspweb1.com/sites/pressrel/?year=2016&month=5

Expecting URL:
http://cmspweb1.com/sites/pressrel/2016/5



Rewrite which I tried:
Code:

RewriteCond %{QUERY_STRING} ^year=(.*)&month=(.*)
RewriteRule ^(.*)$ http://cmspweb1.com/sites/pressrel/%1/%2/?


Quote:

Should we have the folder "http://cmspweb1.com/sites/pressrel/2016/5" exist in system or its required for URL rerouting?


Kindly please help me to make it work.

Thanks
Jayaram
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Mon 06 Jun '16 18:13    Post subject: Re: Help on Removing Query String from the URL Reply with quote

jponnusamy wrote:

Should we have the folder "http://cmspweb1.com/sites/pressrel/2016/5" exist in system or its required for URL rerouting?


No, I think the problem is you are going about this in reverse.

Usually you rewrite the URL the client is asking for (search engine friendly url) and change it to match what the script wants (i.e. the query string). So, anything that links to the script needs to be done as http://cmspweb1.com/sites/pressrel/2016/5 and you rewrite that to become http://cmspweb1.com/sites/pressrel?year=2016&month=5 which is what the script speaks so to say.
Back to top


Reply to topic   Topic: Help on Removing Query String from the URL View previous topic :: View next topic
Post new topic   Forum Index -> Apache