Jump to content
phdphd

Variable Not Processed In .htaccess

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 !

 

 

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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]

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

For those who might be interested

RewriteCond %{QUERY_STRING} tech=(.*)
RewriteRule go-and-fetch search.php?options=del&cat=tech&code=%1 [L]

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

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.