Forum Moderators: phranque
A User requests a page like test.com/samy.john. But this page does not exist, so he will get redirected to /index.html and in the headline of index.html there will be a message that says Hello Samy which is taken from the first part of the URL
he requested.
the rewrite rule for redirect to index.html is done and working as following :
rewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* /index.html [R,L]
but how to display the 1st name on the index.html page after redirect anyone can help me with code
thanks
To do this you will need to set a cookie to store the user information, unless you are prepared to pass the parameters in the URL itself.
To use the cookie method, internally rewrite the URL to a script which can set a cookie, and then issue the redirect via that script.
so any request like test.com/xsamy.john
will be redirect to test.com/index.html
index.html is normal html page
the part i cant do as code is when user redirect from page he request like test.com/andy.samy
he got welcome msg at index.html
say Hello $1stnameof url like Hello Andy
this my goal :)
So, my suggestion is that you do not redirect with htaccess. Instead you rewrite to a PHP script which will be able to set the cookie and perform the redirect.
In htaccess, something like
RewriteRule ^(.*)$ /index.php?name=$1 [L]
Then, in index.php store the username using a cookie [google.com] and then output a redirect [google.com].