My website has several files and folders:
mywebsite.com/index.php
mywebsite.com/files/...
Our users asked me if it would be possible to create url alias like this:
mywebsite.com/thisalias -> mywebsite.com/index.php?var=thisalias
With other words: if the folder/file "thisalias" doesn't exist, it should redirect. I have tried several code samples from StackOverflow but for some reason it didn't work on my host. Any suggestions? I'm not really good with .htaccess coding.
I believe this is what you are looking for.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/([a-zA-Z0-9]+)$ index.php?var=$1 [L]
</IfModule>
Related
i want to rewrite the url http://www.host.com/de/rss to the file http://www.host.com/index.php?type=9000001&L=1
My rewrite rule look like this:
RewriteRule ^de/rss(.*) index.php?type=9000001&L=1
But this does not work. If i delete de/ it works with the corresponding url.
I tried to look for similar questions here on stackoverflow, but that didn´t help.
Use this code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^de/rss/?$ index.php?type=9000001&L=1 [L,QSA,NC]
And if doesn't work then please post your full .htaccess in your question.
Maybe you should try this:
RewriteRule ^/de/rss.*$ /index.php?type=9000001&L=1
Okay, so I have a script that works like adf.ly; you submit a URL, the Url is shortened and then an interstitial advertisement shown before you're taken to your URL. I have the following .htaccess located in the root:
DirectoryIndex index.php
FileETag none
ServerSignature Off
Options All -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([0-9a-zA-Z]{1,6})$ fly/?to=$1 [L]
RewriteRule ^([0-9]{1,9})/banner/(.*)$ fly/?uid=$1&adt=2&url=$2 [L]
RewriteRule ^([0-9]{1,9})/(.*)$ fly/?uid=$1&adt=1&url=$2 [L]
</IfModule>
The script is generating the shortURL's (you can try here: http://www.twitsym.com/short/) however it is not redirecting to fly.php and then the final URL. I'm terrible with .htaccess and have little to no knowledge. Can anybody edge me further as to what might be causing the problem?
Directory structure is:
.../
.../fly/index.php
Thank you again, StackOverflow!
it seems that you will need the LogLevel directive somewhere in your httpd.conf or vhost.conf if this is a virtual server. See this post for a similar question.
The code would be:
RewriteLogLevel 3
RewriteLog "/usr/local/var/apache/logs/rewrite.log"
Where is the htaccess supposed to be redirecting to (i.e. which URL should lead whereto?)
Additionally, you asked for being redirected to fly.php, however it does not occur in your .htaccess. Was this your intention?
I'm having some mod_rewrite problems with my .htaccess..
RewriteBase /folder
RewriteEngine on
RewriteRule ^(.*)$ basic.php?url=$1 [L]
Above is what I'm currently using. However, I have no idea what I'm doing to be honest as I'm just cycling through the internet trying to figure this out.
Basically, for my website, if you type in
www.domain.com/folder/xxx/
I want it to basically be www.domain.com/folder/basic.php?url=xxx.
For some reason, all that does is cause a 404 error :/
So can someone please politely point me in the right direction?
Ok, I will explain using your htaccess.
RewriteEngine on
Turn on the Rewrite Module to enable URL rewriting
RewriteBase /folder
Rewrite the Base Directory to directory name folder
RewriteRule ^folder/(.*)$ basic.php?url=$1 [L]
Remap every request make using the folder/***** to basic.php?url=********
Note: RewriteEngine On Should be the first statement on your case
RewriteEngine on
RewriteBase /
RewriteRule ^folder/(.*)$ folder/basic.php?url=$1 [L]
This is more of a problem with regexs than .htaccess files.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html
http://www.regular-expressions.info/
I own this website: http://www.finalyearondesk.com .
I want to change the url like :
http://www.finalyearondesk.com/index.php?idname=how-to-recover-ubuntu-after-it-is-crashed
to something like this:
finalyearondesk.com/posts/how-to-recover-ubuntu-after-it-is-crashed
using .htaccess. I don't have any knowledge of .htaccess, and I tried a lot of tutorials available online but all effort goes to vain.
So tell me how to do this.
Create a .htaccess file with this content:
RewriteEngine On
RewriteRule ^posts/([^/]*)$ /index.php?idname=$1 [L]
If it doesn't work, check that the file begins with a dot, that your hoster allows you to use .htaccess files or try to add Options +FollowSymLinks:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^posts/([^/]*)$ /index.php?idname=$1 [L]
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
.htaccess for cakephp
I use this code for htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Inside this folder,
root/
app/
app/webroot
But not work
My live path is http://www.jacksonwebservices.co.uk/
you should be running with the default cake supplied .htaccess files. there is nothing wrong with them for the most part. it seems like the .htaccess files are not readable by the webserver.
check your logs for more info.
Do you have that same .htaccess file in each of those directories? You need a different one in each of them. See http://book.cakephp.org/#!/view/917/Apache-and-mod_rewrite-and-htaccess for details.
I am guessing you are having the same Rewrite base problem that I recently had, put this in your .htaccess instead:
<IfModule mod_rewrite.c>
RewriteBase /
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Sometimes it doesn't work without the 'RewriteBase' line at the top.
EDIT: DO AS JUHANA SAYS: Make sure you have the correct htaccess files in the correct locations. They are all different. If it is as you describe, webroot is redirecting to itself redirecting to itself redirecting ...
Does your website have mod_rewrite enabled?
Create a file that contains just this:
<?php
phpinfo();
?>
and save it as phpinfo.php in your document root (public_html, www or whatever)
Navigate to that page (http://www.jacksonwebservices.co.uk/phpinfo.php) and search the page for 'rewrite'. If you can't find it it's not enabled and CakePHP will not work in the default mode. See the manual for alternatives: http://book.cakephp.org/view/917/Apache-and-mod_rewrite-and-htaccess
You may need to contact your hosting to get it enabled or to find out how to do it yourself.