phdphd Posted September 29, 2018 Share Posted September 29, 2018 Hi All, So far the following line works. RewriteRule go-and-fetch([.*]) search.php$1 [L] What I want to is refining the variable because its contents is not user friendly enough. For example it might look like ?options=del&cat=tech&code=teinte_id_005 So I tried this line, which does not work RewriteRule go-and-fetch-tech-([.*]) search.php?options=del&cat=tech&code=$1 [L] Note that the following line would work : RewriteRule go-and-fetch-tech-teinte_id_005 search.php?options=del&cat=tech&code=teinte_id_005 [L] Thanks ! Quote Link to comment https://forums.phpfreaks.com/topic/307737-variable-not-processed-in-htaccess/ Share on other sites More sharing options...
requinix Posted September 29, 2018 Share Posted September 29, 2018 7 hours ago, phdphd said: So far the following line works. RewriteRule go-and-fetch([.*]) search.php$1 [L] No, I don't believe it does. What is the URL you want to see in the address bar and what is the URL it needs to be translated to by the server? Quote Link to comment https://forums.phpfreaks.com/topic/307737-variable-not-processed-in-htaccess/#findComment-1561201 Share on other sites More sharing options...
phdphd Posted September 29, 2018 Author Share Posted September 29, 2018 39 minutes ago, requinix said: No, I don't believe it does. What is the URL you want to see in the address bar and what is the URL it needs to be translated to by the server? Hi Requinix, First of all, thanks a lot for coming again to my rescue. Much appreciated. What you wrote is very interesting & instructive. When I started to build my htaccess file I wrote a line that looks like.... RewriteRule go-and-fetch search.php [L] ... in order for the URL to look user friendly from the very first time the page would be loaded. It turned out that afterwards I made some updates to my page essentially by designing an area that gathers the criteria chosen by the user and where they can selectively click a specific criterion to delete it. That is where comes into play the "?options=xxxxx" part of the URL. So to keep the user-friendly URL also in the cases where the user deletes a criterion, I thought I needed to add the following line RewriteRule go-and-fetch([.*]) search.php$1 [L] Actually this line seems useless. I have just made some tests with just the other line enabled, and "go-and-fetch" always displays in the address bar either alone (like when first loading of the page) or followed by the "?options=xxxxx" part that corresponds to the criteria that the user clicked in order to delete it. Quote Link to comment https://forums.phpfreaks.com/topic/307737-variable-not-processed-in-htaccess/#findComment-1561202 Share on other sites More sharing options...
requinix Posted September 29, 2018 Share Posted September 29, 2018 If you're just adding a query string, so go-and-fetch?options=whatever, then you don't have to do anything in your .htaccess. Quote Link to comment https://forums.phpfreaks.com/topic/307737-variable-not-processed-in-htaccess/#findComment-1561203 Share on other sites More sharing options...
phdphd Posted September 29, 2018 Author Share Posted September 29, 2018 5 minutes ago, requinix said: If you're just adding a query string, so go-and-fetch?options=whatever, then you don't have to do anything in your .htaccess. Yes. And to make the query string more user friendly, I removed the square brackets. RewriteRule go-and-fetch-tech-(.*) search.php?options=del&cat=tech&code=$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/307737-variable-not-processed-in-htaccess/#findComment-1561204 Share on other sites More sharing options...
requinix Posted September 29, 2018 Share Posted September 29, 2018 You cannot make a query string more friendly. Well, you can, but not in the way you're thinking. What you do is not use a query string at all. What you have now means something like go-and-fetch-tech-123 will go to search.php. Is there a problem with it? Are you going to crusade against query strings and anything else that doesn't look readable? Quote Link to comment https://forums.phpfreaks.com/topic/307737-variable-not-processed-in-htaccess/#findComment-1561205 Share on other sites More sharing options...
phdphd Posted September 30, 2018 Author Share Posted September 30, 2018 For those who might be interested RewriteCond %{QUERY_STRING} tech=(.*) RewriteRule go-and-fetch search.php?options=del&cat=tech&code=%1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/307737-variable-not-processed-in-htaccess/#findComment-1561211 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.