Forum Moderators: phranque
RewriteEngine on
RewriteRule ^/catid/([0-9]+)$ /test/index.php?catid=$1 [R]
ReWriteRule ^/pag/([a-z]+)$ /test/index.php?pag=$1 [R]
ReWriteRule ^/pag/css/([a-z]+.[a-z]+)$ /test/css/$1 [R]
ReWriteRule ^/pag/images/([a-z]+_[0-9]+.jpg)$ /test/images/$1 [R]
ReWriteRule ^/catid/uploads/([a-z]+.jpg)$ /test/uploads/$1 [R]
ReWriteRule ^/catid/css/([a-z]+.[a-z]+)$ /test/css/$1 [R]
ReWriteRule ^/catid/images/([a-z]+_[0-9]+.jpg)$ /test/images/$1 [R]
ReWriteRule ^/catid/uploads/([a-z]+.jpg)$ /test/uploads/$1 [R]
RewriteRule ^/subcat/([0-9]+)$ /test/index.php?catid=$1 [R]
ReWriteRule ^/subcat/css/([a-z]+.[a-z]+)$ /test/css/$1 [R]
ReWriteRule ^/subcat/images/([a-z]+_[0-9]+.jpg)$ /test/images/$1 [R]
ReWriteRule ^/subcat/uploads/([a-z]+.jpg)$ /test/uploads/$1 [R]
######################################################################
[edited by: jdMorgan at 4:46 pm (utc) on June 2, 2005]
[edit reason] No URLs, please. See TOS. [/edit]
see this link here i have some links like
http://206.***.164.234/send-gifts-to-pakistancom/log/1.html
http://206.***.164.234/send-gifts-to-pakistancom/log/2.html
now what i want is to redirect these links to :::
http://206.***.164.234/send-gifts-to-pakistancom/test.php?log=1
and
http://206.***.164.234/send-gifts-to-pakistancom/test.php?log=2
here is my .htaccess file code....
--------------------
Options +FollowSymlinks
rewriteengine on
RewriteRule ^/log/([0-9]).html$ http://206.***.164.234/send-gifts-to-pakistancom/test.php?log=$1 [R]
-------------------
and it does not works. can u plz. help me out?
Thanks in advance...
[edited by: jdMorgan at 1:59 am (utc) on June 7, 2005]
[edit reason] De-linked. [/edit]
Options +FollowSymlinks
rewriteengine on
RewriteRule ^/log/([0-9]).html$
This does not work, because the above rule is looking for a / to start the file, but Apache strips the preceding / in the htaccess file.
RewriteRule ^log/([0-9]+)\.html$
The + is added in case you have more than one number EG 11, \. rather than .(dot) makes sure only a true .(dot) character is matched, rather than 'any character except a line break'. It is also wise to add a L 'last' flag to your directives [R,L], unless you know you do not need it. Finally, the R defaults to a 302 temporary redirect, so it is normally better to add R=301, for a permanent move.
Your full rule would end up looking something like this: (assuming it is in the correct directory to 'catch' the request for the file)
RewriteRule ^log/([0-9]+)\.html$ http://yoursite.com/send-gifts-to-pakistancom/test.php?log=$1 [R=301,L]
Hope this helps.
Justin
No. Without the [L] flag, all redirections are deferred until all rules have been processed. In the case of internal rewrites, invokation of the content-handler is similarly deferred. Always use [L] unless you have a specific reason not to -- i.e. always use it unless you really do want to process the output from the current rule through one or more subsequent rules.
There are occasions when you want to do a multi-step rewrite using several rules in sequence, and in those cases, then omitting [L] is correct. But these cases are relatively rare in simple Web site configurations.
Jim
RewriteEngine on
RewriteRule ^log/([0-9]+)\.html$ http://206.***.164.234/send-gifts-to-pakistancom/test.php?log=$1 [R=301,L]
so when i type
http://206.***.164.234/send-gifts-to-pakistancom/log/1.html
in my browser it should send me to http://206.***.164.234/send-gifts-to-pakistancom/test.php?log=1 but it does not work. you can chek the above link man. let me add one thing tht both .htaccess file and test.php are in same directory.
mani
[edited by: jdMorgan at 7:10 am (utc) on June 7, 2005]
[edit reason] No URLs, no IP addresses, please. [/edit]
Does the redirect start?
Do you get a server error?
Do you get a 404 error?
What directory is your .htaccess file in?
If the .htaccess is in: (the main directory)
206.***.164.234/
You will need to move it to: send-gifts-to-pakistancom/
or add send-gifts-to-pakistancom/ to your rule.
RewriteRule ^send-gifts-to-pakistancom/log/([0-9]+)\.html$ [206.***.164.234...] [R=301,L]
If it is in log/ you will need to remove the log/
RewriteRule ^([0-9]+)\.html$ [206.***.164.234...] [R=301,L]
If none of these solve the problem, please post exactly what does not work, and any errors from your server logs.
Justin
This is the .htaccess file code.
RewriteEngine on
RewriteRule ^log/([0-9]+)\.html$ [206.169.164.234...] [R=301,L]
and test.php is also at root.
wot else
but in result my rewrite does not work.
RewriteEngine on
RewriteRule ^old.html$ new.html [R]
-----------------------------------
and i am testing it on the following links but it does not works, my .htaccess file is present in test foler and my new.html and old.html both are also in test folder.
http://example.com/test/new.html
http://example.com/test/old.html
any help plz..........
[edited by: jdMorgan at 6:11 pm (utc) on Aug. 18, 2005]
[edit reason] Removed URLs per TOS. [/edit]
I am not sure what you mean by doesn't work, but I would recommend trying this:
RewriteRule ^old.html$ /test/new.html [R]
In the .htaccess file the full path to the directory should be used, because the request is 'sent back' to the server root as a new request after the redirection happens.
If this does not correct the issue, please post exactly what you mean by does not work... Server error? 404 error? No rewrite?
Hope this helps.
Justin
** Rewrites work regardless of whether the files are present/exist or not.
[edited by: jd01 at 9:05 am (utc) on June 7, 2005]
RewriteEngine on
RewriteRule ^old.html$ /test/new.html [R]
i want my server to send :
http://www.example.com/test1/old.html
to
http://www.example.com/test1/new.html
what happens as a result of this is => it does not redirects. it gives me tht page does not found. this is the whole problem. bottom line is redirect is not working ...
[edited by: jdMorgan at 1:22 am (utc) on June 8, 2005]
[edit reason] No URLS. Please see Terms of Service. [/edit]
The first rule does an external redirect, and your browser address bar should change to show /test/new.html. The second rule does an internal rewrite, and is "silent."
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^old.html$ http://www.example.com/test/new.html [R=301,L]
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^old.html$ /test/new.html [L]
Jim
RewriteEngine on
RewriteRule ^old.html$ /test/new.html [R,L]
Will not work for this:
i want my server to send :
http://www.example.com/test1/old.html
to
http://www.example.com/test1/new.html
Unfortunately, rewrites have to be exact, the rule you are using redirects to the /test/ directory, but your example states test1.
You would need to use this for test1:
RewriteRule ^old.html$ /test1/new.html [R,L]
Added: Flags to rules. Oops!
Justin
shortandsweet1.html
frustrating.php
.htaccess
here is my .htaccess file code.
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^shortandsweet.html /frustrating.php
now when i type ==>> [localhost...]
in my browser instead of redirecting me to [localhost...] it shows the page with message
Not Found
The requested URL /rewrite-testfolder/shortandsweet.html was not found on this server.
--------------------------------------------------------------------------------
Apache/1.3.23 Server at localhost Port 80
-----------------
any solution pzl..........
--------------------------------------------------------------------------------
Please try the following:
If you typed the page address in the Address bar, make sure that it is spelled correctly.
Open the localhost home page, and then look for links to the information you want.
Click the Back button to try another link.
Click Search to look for information on the Internet.
HTTP 404 - File not found
Internet Explorer
-------------------
Muhammad Abdul Mannan
Islamabad, Pakistan
Thanks.
Muhammad Abdul Mannan
Islamabad, Pakistan