I am trying to redirect
http://www.indiegamers.co.uk/post?id=1
to
http://www.indiegamers.co.uk/post/1
This is the .htaccess file I am using, but it is not passing the URL string
RewriteEngine On
RewriteCond ^/post/([^/]+) /post?id=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
Options +Indexes -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^post/(.*)/? post.php?id=$1 [L]
Try this
Related
I want to pass a string (p=number) to all the URL in my website
Example:
www.abc.com/p/1/my-filename-1
www.abc.com/p/2/my-new-filename-anything
This is my current code but it is not working:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -Multiviews
RewriteEngine On
# Remove .php file extention
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
# For individual page url
#RewriteRule ^p/(.*)\.php $1.php?p=$2
</IfModule>
Try this rule, here we are getting digit from url and assigning it to the respective file with removed extension.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)/$ $1.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^p/([\d]+)/([\w-]+)$ $2.php?id=$1 [NC,L]
I have a domain eg: abc.com. While displaying news the url will be abc.com/news.php?news=xyz. And i want to change the url to something like news.abc.com/xyz.
Is it possible via .htaccess
use this code
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{HTTP_HOST} !^www.site.com [NC]
RewriteCond %{HTTP_HOST} ([^\.]+).site.com [NC]
RewriteRule ^(.*)$ %1.php?%1=$1 [L,NC]
</IfModule>
use this code in htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ news.php?news=$1 [QSA,L]
</IfModule>
I have PHP file .htaccess :
Options -Multiviews
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?user=$1
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/home/.*$ index.php [QSA]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/friends$ friends.php?user=$1 [L]
RewriteEngine On
RewriteRule ^post/(\d+)/([a-z-]+) post.php?id=$1&title=$2 [L]
Now I want the url post to be like this :
http://example.com/yoana/post/id_post
I tried with that rule above, but it is still not working.
The error is :
Object not found!
Any ideas?
I'm trying to remove .php from my url,
below is my .htaccess contents
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /folder/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ path.php?username=$1 [L,QSA]
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L]
</IfModule>
I don't have any idea what's going wrong.
Try this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
You need an additional rule to redirect .php URL to non-php one. Try this code:
Options -MultiViews
RewriteEngine On
RewriteBase /folder/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ path.php?username=$1 [L,QSA]
RewriteCond %{THE_REQUEST} \s/+folder/(.+?)\.php[\s?] [NC]
RewriteRule ^ %1? [R,L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
I am quite new to mod rewrite and i have this, which is not working.
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /kitnes/cache/dynamic/$1.htm
RewriteRule /kitnes/cache/dynamic/([^/\.]+).htm index.php?id=$1 [NC,QSA,L]
the rewritten URL is something like this http://www.ghananewsportal.com/1.1629334 and i would like it to redirect to http://www.ghananewsportal.com/?id=1.1629334 if the rewritten URL fails.
thanks.
Something like this should work:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/kitnes/cache/dynamic/$1.html -f
RewriteRule ^(.+)$ /kitnes/cache/dynamic/$1.htm [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?id=$1 [QSA,L]