.htaccess file is not working...
I don't know Why ??
Help me out here is my code
.htaccess file
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Rewrite
Rule ^(.*)$ index.php?name=$1 [QSA,L]
and php file.
if (isset($_GET['usernamess']) === true && empty($_GET['usernamess']) === false) {
$usernamess = $_GET['usernamess'];
echo $usernamess;
}else {
header('index.php');
}
Try this in your Root/.htaccess file :
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php\?name=([^\s]+) [NC]
RewriteRule ^ /%1? [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?name=$1 [QSA,L,NC]
and name and usernamess should be the same
Related
I am tring to convert:
http://localhost/mysite/blog.php?slug=post-by-paritosh
To :
http://localhost/mysite/blog/post-by-paritosh
For that I am using .htaccess file with below rules
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?blog/(.*?)/?$ /blog.php?slug=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /blog\.php\?slug=([^\&\ ]+)
RewriteRule ^/?blog\.php$ /blog/%1? [L,R=301]
After checking syntax on http://www.htaccesscheck.com/ I found that it is ok but the rewrite are not working as expected.
You may try this .htaccess inside tgconnectmediaservice/ directory:
Options -MultiViews
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+(tgconnectmediaservice/blog)\.php\?slug=([^&\s]+)\s [NC]
RewriteRule ^ /%1/%2? [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?blog/([^/]+)/?$ blog.php?slug=$1 [L,QSA,NC]
I need open file.php as index on my website. On homepage will be opened file.php without redirect to www.website.com/file.php
Second rewrite rule is redirect www.website.com/?id={id} to www.website.com/{id}
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ file.php?id=$1
RewriteRule ^$ /file.php
RewriteCond %{QUERY_STRING} ^(.*&)?id=([^&]*)(&.*)?$
RewriteRule ^ %{REQUEST_URI}?%1%2%3
Help me with htaccess code?
You can have your rules like this:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+\?id=([^\s&]+)\s [NC]
RewriteRule ^ /%1? [R=301,L,NE]
RewriteRule ^$ /file.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ file.php?id=$1 [L,QSA]
I want to redirect the url : https://WEB_URL/video?id=1 to https://WEB_URL/video/1
and I have written following htaccess code but it is not working :
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^video/([^.]*)$ video?id=$1 [QSA,L]
My full htaccess code is as follows:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteEngine On
ErrorDocument 404 /login.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# To externally redirect /dir/abc.php to /dir/abc
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)/?$ $1.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^video/([^.]*)$ video?id=$1 [QSA,L]
</IfModule>
why it is not working ? What I am doing wrong please help me on this.
Thanks in advance.
Try this:
ErrorDocument 404 /login.php
Options -MultiViews
RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /video(?:\.php)?\?id=([^\s&]+) [NC]
RewriteRule ^ /video/%1? [R=302,L,NE]
# To externally redirect /dir/abc.php to /dir/abc
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)\.php[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^video/([^.]+?)/?$ video.php?id=$1 [QSA,L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^.]+?)/?$ $1.php [L]
I need to redirect
http://mysite.com/mp3/-angel-la-pared-shakira-/
to this
http://mysite.com/mp3/angel-la-pared-shakira/
this is my htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mp3/(.*)/$ search.php?q=$1
RewriteEngine On
RewriteRule (.*)\.xml sitemap.php [nocase]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*[^/]$ /$0/ [L,R=301]
Add this to the beginning of your htaccess file:
RewriteRule ^mp3/-([^/]+)-/$ /mp3/$1/ [L,R=301]
Sorry that i'm new on htaccess and have a issue now.
I was able be redirect from domain.com/admin to www.domain.com/admin
But failed with domain.com/test which bring me back to www.domain.com, and it's fine if i go in with fullname www.domain.com/test
Both /admin and /test are valid subdirectory, only different is /admin doesn't have htaccess file but /test do have
this is my home htaccess:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ page_process.php
And this is subdirectory /test htaccess
RewriteEngine on
RewriteBase /test/
RewriteOptions inherit
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /test/page_process.php
Would appreciate any help! Thanks!
Try this code for the htaccess in the root directory :
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /page_process.php
And this code for the htaccess in the test directory :
RewriteEngine on
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ page_process.php