I'm new to this, please have grace...

So I understand changing the .htaccess file to let users type in a new link, and then it reference the old page as seen here:
I want to access 127.0.0.1/site/result.php?par1=var1&par2=var2&par3=var3, by typing in 127.0.0.1/site/var1-var2-var3.html

.htaccess file:
Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(.*)_(.*)_(.*)\.html$ result.php?var1=$1&var2=$2&var3=$3


it works... but now, how do I automatically when I submit the form, get the new link to display? Or in other words, how do when we type in 127.0.0.1/site/result.php?par1=var1&par2=var2&par3=var3 be redirected to 127.0.0.1/site/var1-var2-var3.html?

Any help would be appreciated!

Recommended Answers

All 2 Replies

You have to send the 301 redirect code explicitly as a flag
These flags go in brackets after your RewriteRule. In your case you could try this:

RewriteRule ^(.*)_(.*)_(.*)\.html$ result.php?var1=$1&var2=$2&var3=$3 [R=301, L]

R=301 says "send the 301 permanent redirect"
the L flag says that this is the last flag for this command.

Here is a random googled page for RewriteRule flags:
http://www.htaccesselite.com/mod-rewrite-flags-vt101.html

Good luck!

I had a similar doubt too. Thanks for the link guyinpv.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.