I'm trying to add some rewriting on my site, but it seems to not work, I'm using apache and .htaccess.
The code in my .htaccess file is:
RewriteEngine On
RewriteRule ^/?os_framework/?$ /os_framework/index.php?module=home [L,NC,QSA,PT]
This should send http://localhost/os_framework/ to http://localhost/os_framework/index.php?module=home
But it seems not to.
Any help would be appreciated.
In advance, thanks
Edit: Fixed the above, shouldn't have the os_framework/ in the search pattern, however now i cant get this one to work:
RewriteRule ^/(.[^/]*)/?$ /os_framework/index.php?module=$1 [L,NC,QSA,PT]
And what is wrong with
RewriteRule ^(.[^/]*)/?$ /os_framework/index.php?module=$1 [L,NC,QSA,PT]
Why does that throw a error 500? it should work
Try this:
RewriteEngine On
RewriteRule ^os_framework/?$ os_framework/index.php?module=home [L,NC,QSA]
Related
I'm trying to work out a bigger problem, which I believe lies in my .htaccess file. So I stripped it down to the following for testing purposes:
RewriteEngine on
RewriteRule ^sandbox/htaccess/one.php$ sandbox/htaccess/two.php
I'm simply trying to get requests for
http://example.com/sandbox/htaccess/one.php
to go to
http://example.com/sandbox/htaccess/two.php
However, this is not working. I simply see one.php.
I can confirm that .htaccess file is being read.
What am I missing to get this simple example working?
Try this, it will work
RewriteEngine on
RewriteBase /
RewriteRule ^sandbox/htaccess/one\.php$ /sandbox/htaccess/two.php? [L,R=301]
I'm trying to perform the following redirection in .htaccess file, but I can not make them work. Can you help me?
Redirect is this:
https://www.example.com/example/CL%C3%81SULA%20DE%20MUERTE%20ACCIDENTAL%20CAD220130535.pdf to https://www.example.com/example-cl/images/example.pdf
I tried this:
Redirect 301 "/example/CL%C3%81SULA%20DE%20MUERTE%20ACCIDENTAL%20CAD220130535.pdf" https://www.example.com/example-cl/images/example.pdf
Thank you very much. Regards!
You can use this rule in site root .htaccess (a level above /example/):
RewriteEngine On
RewriteRule ^example/CL\xC3\x81SULA\x20DE\x20MUERTE\x20ACCIDENTAL\x20CAD220130535\.pdf$ /example-cl/images/example.pdf [L,R=302]
This is assuming /example/.htaccess doesn't exist. If you already have /example/.htaccess then use this rule as very first rule:
RewriteEngine On
RewriteRule ^CL\xC3\x81SULA\x20DE\x20MUERTE\x20ACCIDENTAL\x20CAD220130535\.pdf$ /example-cl/images/example.pdf [L,R=302]
I answer to myself.
I was making other redirections and find a good method to use in other similar redirections.
RewriteRule "^example/CL(.*)USULA DE MUERTE ACCIDENTAL CAD220130535.pdf" https://www.example.com/example-cl/images/example.pdf
With this method, this redirection works perfect.
I've installed WAMP, made an alias, and put into that folder a ".htaccess" file. My goal is to have a URL such as "foo.com/blog/bar-baz" internally call "display.php?name=bar-baz". Among various things I tried the following:
RewriteRule ^blog/(.+)$ display.php?$1
However, this gives a "The requested URL /Users/.../public/display.php was not found on this server". Playing around I was able to get this to work:
RewriteRule ^blog.php$ /personal/display.php
Advice greatly appreciated.
You can try this rule from root .htaccess:
RewriteEngine On
RewriteRule ^blog/(.+)$ /personal/display.php?name=$1 [L,QSA,NC]
I know this question is asked by many users, also I gone through many questions to find the solutions as I am unable to understand the code used in htaccess file. So please kindly help me to solve this issue. I just want to convert a link like:
www.abc.com/project.php?proj-cat=some+project+name
to url like:
www.abc.com/project/some+project+name
OR to like:
www.abc.com/project/some-project-name/
I googled and found a website which creates a htaccess rule for you, using this site I got this:
RewriteEngine on
RewriteRule project/proj-cat/(.*)/ project.php?proj-cat=$1 [L]
but this doesn't redirect to the links above.
Please help me to find the solution for this and help me understand how it works. Thank You!
You can use this code in root .htaccess:
RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \s/+project\.php\?proj-cat=([^\s&]+) [NC]
RewriteRule ^ project/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^project/([^/.]+)/?$ project.php?proj-cat=$1 [L,QSA,NC]
Reference: 1. Apache mod_rewrite Introduction
2. http://askapache.com
I have this old survey link that is has been superseded by another link, so basically I want anyone trying to access the URL:
http://mywebsite.com/survey/view_survey.php?surveyID=1
To be redirected to:
http://mywebsite.com/survey/view_survey.php?surveyID=2
Can I do this in the Apache configuration or htaccess file?
I tried the following rule in the Redirect section of my httpd.conf file:
Redirect 301 /survey/view_survey.php?surveyID=1 http://mywebsite.com/survey/view_survey.php?surveyID=2
But it doesn't work. I am suspecting that the GET parameters are not used when processing the rule.
Is my only option to hack my code to redirect on a specific surveyID?
Following the suggestion of using the Rewrite rules, I tried the following in my .htaccess file:
RewriteRule ^survey/view_survey\.php\?surveyID=1525$ /survey/view_survey.php?sur
veyID=1607
But that doesn't work. I do have the rewrite engine up and running, because I have another rewrite rule currently running.
Try this in a .htaccess file:
RewriteEngine on
RewriteCond %{QUERY_STRING} (^|.*&)surveyID=1525(&.*|$)
RewriteRule ^survey/view_survey\.php$ /survey/view_survey.php?%1surveyID=1607%2 [L,R=301]
RewriteEngine On
RewriteCond %{QUERY_STRING} ^surveyID=1525$
RewriteRule ^/survey/view_survey\.php /survey/view_survey.php?surveyID=1607 [R=301]
Check out the QSA portion of the mod_rewrite.
It does GET string manipulation.
There might be a possible duplicate of this question and it is solved if this solution doesnt work for you:
Apache Redirect 301 fails when using GET parameters, such as ?blah=