Jump to content

Variable Not Processed In .htaccess


phdphd

Recommended Posts

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 !

 

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.