Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
While redirecting one page to another page using h t access getting attached extra number to domain
e.g: "domain.com:399" here i need to remove ":399" form domain how to do this?
something like this might work:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} ^/a
RewriteRule (.*) http://[yourdomain]/b/link.php
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
For a project, I need to make every directory (server.com/dir1, server.com/dir2) look like there is the directory, even when there is not. I could say I need a directory wildcard. Say the content would be somewhere on the server, and gets included in the directories. Is there a way to achieve this with .htaccess?
Thanks!
Try something like this
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.+)/*$ ./yourActualScript.php?directory=$1
The regex part in brackets is your folder, the slash star is the rest of the url (if any), and the request will be sent to an actual script with GET var directory
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I'd like to set my Apache server up so that when someone visits, say, site.com/kittens/ (or site.com/kittnes/index.php), they would actually get to view site.com/certainpage.php. Of course I could copy certainpage.php to /kittens/ and rename it index.php, but it seems like a really lame way to do it.
Any help? I feel like this shouldn't be something too complex.
You can use a rewrite rule to keep the URL the same but swap the contents out for that of another file like so:
RewriteEngine On
RewriteRule ^kittens/(index\.php)?$ /certainpage.php [L]
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
How to redirect https://xyz.com/ceoblog/?tag=real-estate-assistant&paged=2 to https://xyz.com/ceoblog/
I have tried all possible solution but its not redirect.
how do I achieve this?
Thanks in advance
This htaccess rule checks for ANY query string on ceoblog and redirects to ceoblog/
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^ceoblog(/?)$ /ceoblog/? [R=301,L]
However, looking at the query string this will stop the pagination and tag filter from working correctly - i.e. you will be stuck with just the one page.
There are a couple possible solutions
If your looking to store the query string data away, and then just redirect to no query string, you could in your php script do something like:
if(count($_GET)) {
$mydata = $_GET;
// do stuff with $data, like store it or something
header("location: /ceoblog");
} else {
// do other stuff
}
If you're looking to just redirect, a simple 301 redirect in an htaccess rule would work perfectly here
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have searched and found solutions that were close, but I have not found anything that is exactly what I'm looking for. I have a two page/step form. I would like all external traffic pointing to page two to be redirected to page one of the form. However, traffic from page one needs to get to page two without being redirected back to page one.
Thanks!
Something like this should work for you:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://example.com [NC]
RewriteRule ^form/page2.php$ http://example..com/form/page1.php [L,R]
Going to http://example.com/form/page2.php will redirect you to http://example.com/form/page1.php unless you are linked to page2.php from within site.com.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
the thing is that im capturing my url based on GET method... so my url looks like
localhost/test/index.php?vic=24
where vic is variable...
ALSO i have a button on my site that is randomizing my vic every time.
<a href="'.htmlentities($_SERVER['PHP_SELF']).'?vic='.randomVic($link).'">
note that randomVic($link) is a function that returns random number every time.
what i want to achieve is that my url looks like
localhost/test/index.php?vic=24 -> localhost/test/24
and so on for every random number.
i really need help on this, i tried numerous .htacces mods for rewrite (striping .php, removing index, ...) but none of them worked as i needed them.
Thanks!
Enable mod_rewrite and .htaccess through httpd.conf (if not already enabled) and then put this code in your DOCUMENT_ROOT/vic.htaccess file:
RewriteEngine On
RewriteBase /vic/
RewriteCond %{THE_REQUEST} \s/+vic/index\.php\?vic=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]
RewriteRule ^([0-9]+)/?$ index.php?vic=$1 [L,QSA,NC]
RewriteRule ^test/([0-9]+)$ index.php?vic=$1
edited as per comment below