I have the php file page.php.
URLS:
page.php?content=contact
page.php?content=aboutus
I need it to be shown like this:
mysite.com/contact
mysite.com/aboutus
I figured out that I have to make .htaccess
RewriteEngine on
RewriteRule ^paginas/([^/]+)/?$ page.php?page=contact [L]
Tryed many things.. No results..
Thanks for attention
Try:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(?:GET|HEAD)\ /+page\.php\?content=([^&\ ]+)
RewriteRule ^ /%1? [L,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ /page.php?content=$1 [L]
This will first redirect: /page.php?content=anything to /anything then internally rewrite back requests like /anything to /page.php?content=anything.
Related
I have a URL like:
http://localhost/admin-s/index.php?m=user
However, I would like a URL like this:
http://localhost/admin-s/user
I try like this:
RewriteRule ^([a-z0-9]+).php$ index.php?nol&m=$1 [L]
RewriteCond %{QUERY_STRING} ^m=([a-zA-Z0-9]+)$
RewriteRule ^index.php$ user%1.php [L]
How to make it?
Hope this simple configuration will help you out. You can check this configuration here
This will redirect request of this pattern from http://localhost/admin-s/index.php?m=user to http://localhost/admin-s/user
Explanation:
1. If REQUEST_URI is /admin-s/index.php
2. If QUERY_STRING is m=someWords
3. Redirect to /admin-s/someWords
.htaccess
RewriteEngine on
Options -MultiViews
RewriteCond %{REQUEST_URI} \/admin\-s\/index\.php
RewriteCond %{QUERY_STRING} m=([\w]+)
RewriteRule ^(.*)$ /admin-s/%1? [R=301,L]
The question was answered here : How to turn dynamic URL into static URL
For your problem may be try following rules:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^admin-s/([^-]+) /index.php?m=$1 [R=301,QSA,L]
Let us know if it works
You can use the following rule in your root/.htaccess or /admin-s/.htaccess :
RewriteEngine on
#redirect /admin-s/index.php?m=user to /admin-s/user
RewriteCond %{THE_REQUEST} /admin-s/index\.php\?m=([^\s&]+) [NC]
RewriteRule ^ /admin-s/%1? [L,R]
#rewrite the new uri back to the orignal location
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(?:admin-s/)?(.+)$ /admin-s/index.php?m=$1 [NC,L]
Try below in your admin-s direcotry,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([\w-]+)$ index.php?m=$1 [L]
I'm basics to htaccess. I have an issue with htacess SEO Friendly URL.
For Ex:
If the URL is like www.example.com/A then htaccess should redirect to browse-category.php?alphabet=$1
My Code, but not working:
RewriteCond %{REQUEST_URI} [a-zA-Z]{1}$
RewriteRule ^([a-zA-Z0-9-/]+)$ browse-category.php?alphabet=$1
If URL is like this www.example.com/add-business then it should redirect to $1.php.
Please help me and thanks in advance
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
# if a matching .php file exists then internally forward /file to /file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]
# otherwise forward to browse-category.php?alphabet=$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ browse-category.php?alphabet=$1 [L,QSA]
I have dynamic URL website (irasol.com) while i navigate to menu the url shows like
http://irasol.com/index.php?id=1
I want url like this
domainname/home
domainname/aboutus
domainname/contactus
domainname/apply
home, aboutus, contactus, apply are menu name it is already in database.
my htaccess file is
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([^/]*)\.php$ /index.php?id=$1 [L]
Use this instead:
Options -Multiviews
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+index\.php\?id=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+)/?$ index.php?id=$1 [B,L]
Explanation
The first three conditions make sure that domainname/aboutus is not a real file, so that we don't rewrite files that already exist.
Options -Multiviews removes a number of potential problems
In your current code, get rid of the .php in your pattern:
RewriteRule ^([^/]+)$ /index.php?id=$1 [L]
You are not matching .php extensions in the request. You are only routing matches to a query string on a real .php extension
As for a better solution:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/?$ index.php?id=$1 [L]
I am creating a form at poll.php?code=STRINGHERE
I want to rewrite it with .htaccess to do WEBSITE.com/STRINGHERE
I have done it before but don't remember what I need to do in the .htaccess its something like
RewriteEngine On
RewiteRule ^(\w.+)$ ./poll.php?code=$1
Although I might be wrong. Any help would be great.
Try:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewiteRule ^([^/]+)$ ./poll.php?code=$1 [L,QSA]
And if you need to redirect the browser when requests are made directly to poll.php:
RewriteCond %{THE_REQUEST} \ /+poll\.php\?code=([^&\ ]+)
RewriteRule ^ /%1? [L,R]
I have big problem with my urls. I know how to remove index.php form url, but problem is that I don't know to remove that "?act=" from url.
My link now is http: //localhost/doctrine/public/?act=test and I want to create it like http: //localhost/doctrine/public/test.
My current .htaccess file placed in public folder:
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I need help how to do that.
Use this code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /doctrine/
RewriteRule ^(public)/([^/]+)/?$ $1/?act=$2 [L,QSA,NC]
# Removes index.php from ExpressionEngine URLs
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Before your expression engine rule, you can add:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /doctrine/public/?act=$1 [L]
To internally rewrite a request like http: //localhost/doctrine/public/test to /doctrine/public/?act=test. You need to make sure the links in your content look like /doctrine/public/test instead of the one with the query string. If there are links outside of your control (like google indexed pages) you can add this:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /doctrine/public/?\?act=([^&\ ]+)
Rewrite Rule ^ /doctrine/public/%1? [L,R=301]
to point browsers to the URL without the query string.
This unfortunately isn't going to be compatible with your expression engine URLs.