I want URL rewriting solution.
I have this URL [http://dailyimage.in/photo.php/1480]
and I want to hide .php or [http://dailyimage.in/photo/1480] this type URL
Now I am using this code but it's not working in my .htaccess file
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
Try instead of using %{REQUEST_FILENAME}.php using %{REQUEST_URI}.php in your rewrite destination :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_URI}.php [QSA,L]
Related
I have one HTML page. Assume the URL is
http://localhost/local/local.html
but i want to mask the URL as
http://localhost/local/abc
can we do like this?
Create a .htaccess file in your root of your domain and add the following in that file:
RewriteEngine On
RewriteRule ^local.html$ http://localhost/local/abc/ [R=301,L]
In .htaccess add lines:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?query=$1 [QSA,L]
When you visit https://localhost/local/abc in index.php parse $_GET["query"] how you want.
You can achieve the required action using a htaccess rule ,
Learn about htaccess at :
What is .htaccess file?
.htaccess rule you can implement is follows :
Options +FollowSymlinks
RewriteEngine on
rewriterule ^local/local.html (.*)$ http://localhost/local/abc$1 [r=301,nc]
I want to redirect this url
http://192.168.1.101/project/test/wordpress/wp-content/uploads/2013/06/Sunset.jpg
to this with main url as following.
http://192.168.1.101/project/test/wordpress/redirect.php?file=http://192.168.1.101/project/test/wordpress/wp-content/uploads/2013/06/Sunset.jpg
If url contain extension like .jpg, .png, .jpeg, .bmp, .png then move all it to redirect.php with file name like.
http://192.168.1.101/project/test/wordpress/redirect.php?file=imagefile
My current .htaccess code
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project/test/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /project/test/wordpress/index.php [L]
</IfModule>
# END WordPress
Please Help Me..
Insert this line just after RewriteBase line:
RewriteRule ^wp-content/.+?\.(jpe?g|png|gif|bmp)$ redirect.php?file=http://%{HTTP_HOST}%{REQUEST_URI} [NE,R=302,L,NC]
Once you verify it is working fine, replace R=302 to R=301. Avoid using R=301 (Permanent Redirect) while testing your mod_rewrite rules.
I am looking for a way to create a short URL path for a longer URL on my page
the long url is: domain.com/tagcloud/user.html?t=1234ABCD
i would like to offer a short version of the URL to easy access it:
domain.com/t/1234ABCD
I tried a few examples but I just don't get it how I could forward these rules.
RewriteRule ^(.*)/t/$ /tagcloud/user.html?t=$1 [L]
I am also using MODX so they already use rules.
in addition my htaccess file
RewriteEngine On
RewriteBase /
# Always use www
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.domain\.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
I must keep the code snippets above in my htaccess file. The first one simply forwards http://domain.com requests to www.domain.com
The friendly URLs part is needed to translate the internal IDs of my CMS with the alias of the URL. This feature must remain because the entire site cannot be influencted by the changes I try to make in htaccess...
I simply would like to add a listener that only if the URL matches www.domain.com/t/abcd1234
Therefore I need something that identifies the www.domain.com/t/ URL
your help is much appreciated
Try this:
RewriteCond %{REQUEST_URI} ^/t/.*
RewriteRule ^t/(.*)$ /tagcloud/user.html?t=$1 [R=301,L]
I have a shopping mall site built with Magento. The url is like http://exampleshopping.com
Now I have requirement where each of my users will have a vanity URL like the following -
http://abc.exampleshopping.com
http://xyz.exampleshopping.com
In the above example abc, xyz are the user names.
How is this possible without creating a sub domain from the control panel. I need this to be created automatically when a user registers.
Create an .htaccess file with the following code to build a dynamic username as subdomain.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.exampleshopping\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.exampleshopping\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?username=%1 [L]
All visits to http://username.exampleshopping.com will redirect to www.exampleshopping.com/userpage.php?username=subdomain. User only see http://username.exampleshopping.com in the address bar.
Reference : http://www.panolee.com
Use the following code in your main .htaccess file (for the www subdomain) - or in the Apache Vhost config.
Replace sonassi.com and paths to suit.
RewriteEngine On
RewriteCond %{HTTP_HOST} !www\.sonassi\.com
RewriteCond %{HTTP_HOST} ([^\.]+)\.sonassi\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?user=%1$1 [L]
You need to also create a wildcard DNS A record, if you are using cPanel, you would use
*.sonassi.com => my.ip.add.ress
Or, if you are using TinyDNS - use the following syntax
+*.sonassi.com:my.ip.add.ress:86400
Using a htaccess regex url Rewrite will work for you.
I'm at a total loss trying to integrate a mod_rewrite in my existing page. Currently, I am building a new site from scratch, and there i have some nice clean url's such as:
http://www.example.nl/nl/example
The old site, running Cms made simple, has some not-rewritten url's that would need to be redirected to the new pages. Those url's look like this:
http://www.example.nl/index.php?page=cake-and-pie&hl=nl_NL
But shorter versions of that like:
http://www.example.nl/index.php?page=cake-and-pie
also work.
It took me a while to figure out that url's with parameters cannot simply be redirected with "Redirect 301", like i'd normaly do. So i tried some online mod_rewrite generators like this and this, but the rules outputted by those result only in 404 errors, (the redirect doesn't work at all).
My .htaccess file current looks like this:
RewriteEngine On
RewriteBase /
# remove .php;
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)/index$ $1/ [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
The old pages would seize to exist.
How do i redirect the old pages to the new ones?
Thanks.
EDIT
RewriteCond %{QUERY_STRING} =page=pie
RewriteRule ^index\.php$ /nl/? [L,R=301]
RewriteCond %{QUERY_STRING} =page=pie&hl=nl_NL
RewriteRule ^index\.php$ /nl/? [L,R=301]
Seems to do the trick. This is of course manual for every url, but i only have a few.
RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/([^/]+)/?$ index.php?page=$1&hl=$2
RewriteRule ^([^/]+)/?$ index.php?page=$1 [QSA]