I am trying to change the URL from:
/chat/create?ref=9dsda to /chat/create/refer/9dsda
However, everytime I go to the lather, I get the error:
Not Found: The requested URL /chat/create/ref/9dsda was not found on this server.
This is my .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/create/refer/([^/]+) /create?ref=$1
I've tried several things such as adding RewriteBase /chat/ without success.
If your htaccess is in the root ,try :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^chat/create/refer/([^/]+)/?$ /chat/create?ref=$1 [L]
If it is inside the /chat dir ,try :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^create/refer/([^/]+)/?$ /chat/create?ref=$1 [L]
htaccess is a per-directory context so you don't need to match against the folder that the htaccess is in.
Related
I hosted a website to a sub-directory in a hosting server.
But it is redirected to the main domain when I try to navigate to the sub-url of the website.
So, I added the .htaccess file to solve this problem.
The .htaccess file is the following.
RewriteEngine On
Options FollowSymLinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /#/$1 [L]
But I am getting the problem continuously.
Please let me know how I can solve it.
You can write the following contents to your .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /sub-directory/
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /sub-directory/index.html [L]
</IfModule>
i want to change this URL
domain.com/adsbycat/sub_category.php?category=car-and-buses&category_id=1&sub_category=Car
to
domain.com/car-and-buses/1/Car
i write this code to do this
RewriteEngine On
RewriteBase /domain.com/
RewriteRule ^adsbycat/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ adsbycat/sub_category.php?category=$1&category_id=$2&sub_category=$3
but when i request for new URL it showing 404 not found. please fix this code.
Have this rule in site root .htaccess to rewrite domain.com/car-and-buses/1/Car:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/[^/]+/(.+)$ adsbycat/sub_category.php?category=$1&category_id=$2&sub_category=$3 [NC,L,QSA]
When I go to http://www.example.com/youtube/detail/abvcde in my browser, I want to internally rewrite the url to http://www.example.com/youtube/detail.php?id=abvcde. I tried to do this with the following .htaccess, but it gives a 404 error.
Currently my .htaccess looks like this:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
Put the following code in a htaccess file in server root directory:
RewriteEngine On
RewriteRule ^youtube/detail/(.+)$ youtube/detail.php?id=$1 [L]
You can put this code in your /youtube/.htaccess
Options -MultiViews
RewriteEngine On
RewriteBase /youtube/
RewriteRule ^detail/([^/]+)$ detail.php?id=$1 [L]
I'm having some htaccess issues with my wordpress blog. My previous url's were something like
article-name.html
Now I changed the structure to
blog/article-name.html
But I'm still getting 404 for old url's I shared on various other sites. I've tried adding in htaccess a rule, also tried "redirection" plugin with no success:
and in .htaccess I tried:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!blog/).)*.html$ - /blog/$1.html [L]
</IfModule>
Your regex appears to be a problem, try this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!blog/).+?\.html)$ /blog/$1 [L,R=301,NC]
Change the RewiteBase
But your .htaccess is not an Original WordPress .htaccess. Why you dont use that?
I'm using .htaccess in my public_html folder to redirect my folders to gets:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/])/?([^/])/?$ index.php?v=$1&t=$2
It is giving me a 404 error though when I type my page:
http://southeast.tv/1/e
But it should redirect to:
http://southeast.tv/index.php?v=1&t=e
Make sure you have all of these lines:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/])/?([^/])/?$ index.php?v=$1&t=$2
RewriteRule ^([^/]+)(\/)?([^/]+)? index.php?v=$1&t=$3