I now have:
Order deny,allow
Options +FollowSymlinks
RewriteEngine on
DirectoryIndex index.php
RewriteRule ^en/newsevents$ ?action=setLang&lang=eng&menuid=6 [L,QSA]
It loads my texts but thiks it must look in the /en folder.
This does work, but changes the url from localhost/en/newsevents to localhost/name/?action=setLang&lang=eng&menuid=6
I want that it still remains localhost/en/newsevents
RewriteRule ^en/newsevents$ `http://localhost/name/?action=setLang&lang=eng&menuid=6 [L,QSA]`
Just do this:
RewriteRule ^(en/newsevents)$ $1?action=setLang&lang=eng&menuid=6 [QSA,L]
You need to use passthrough
RewriteRule ^en/newsevents$ ?action=setLang&lang=eng&menuid=6 [PT,L,QSA]
Related
I have a php page and i'm trying to map it with htaccess. The idea is to map the page and if there are no parameters, the page is 1. this is for pagination.
My php page:
<?php echo $page = isset($_GET['p']) ? $_GET['p'] : 1; ?>
In my htaccess file i have this:
RewriteRule ^noticias/ noticias.php [L]
RewriteRule ^noticias/([0-9]+)/?$ noticias.php?p=$1 [L]
If i try to access the page with localhost/example/noticias.php and localhost/example/noticias.php?p=2 everything works.
If i add the first rule, the second rule does not work. And if i remove the first rule, the url wont work.
Tks in advance.
You may use these rules with MultiViews turned off:
Options -MultiViews
RewriteEngine on
RewriteRule ^(noticias)/?$ $1.php [NC,L]
RewriteRule ^(noticias)/(\d+)/?$ $1.php?p=$2 [QSA,NC,L]
Try this in your .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^noticias/?$ noticias.php [QSA,NC,L]
RewriteRule ^noticias/([1-9]+)/?$ noticias.php?p=$1 [QSA,NC,L]
</IfModule>
I am using below code for changing the URL but its not working. My folder structure is: www.abc.com/maindri/index.php
htaccess:
RewriteEngine On
RewriteRule ^home.asp?$ index.php
RewriteRule ^invesys.php?$ invesys-capital.php
RewriteRule ^stocks?$ stocks.php
RewriteRule ^performance?$ performance.php
Trying to change URL for first time.
I would like to show URL in browser home.asp intead that index.php
Try this
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^home\.asp$ index.php [T=application/x-httpd-php,L]
I want to rewrite my URL:
http://jainpopulationregister.com/page.php?action=about
to:
http://jainpopulationregister.com/page/action/about/
with URL rewriting
My current URL rewrite code is as follows:
Options +FollowSymLinks
RewriteEngine on
RewriteRule page/action/(.*)/ page.php?action=$1
RewriteRule page/action/(.*) page.php?action=$1
But when I place this in my root folder, nothing seems to happen. What am I doing wrong?
You want to redirect from
http://jainpopulationregister.com/page.php?action=about
to
http://jainpopulationregister.com/page/action/about/
but your redirect rule does exactly the opposite. Assuming that you really want to redirect from /page.php?action=about to /page/action/about/, use the following configuration in htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^action=(.*)$
RewriteRule ^(.*)$ /page/action/%1/? [R=302,L]
RewriteRule ^page/action/([a-zA-Z0-9]+)/$ pages.php?action=$1 [NC,L]
In "pages.php" file get the action $_GET['action'];
i want rewrite it with a .htaccess i have this url:
../index.php?page=details&id=123456
like this:
../detail/123456
but I do not really know how to do this. Could you help me to rewrite this url?
or give me a simple example that I can understand how it works
RewriteRule ^(.*)/([0-9]+)$ index.php?page=$1&id=$2&%{QUERY_STRING}
The first (.*) selects any string, e.g. "details". ([0-9]+) catches a number, in your case "123456"
Finally
&%{QUERY_STRING}
ensures, that additional parameters are added to your backendscript, too.
This should work:
RewriteEngine On
RewriteRule ^detail/([^/]*)$ /index.php?page=details&id=$1 [L]
Here is an example I use for my webpage when it's in a subdirectory.
# "learn/degree/index.php?d=mathematics" shows as "learn/degree/mathematics"
RewriteRule ^learn/degree/([a-zA-Z_-]+)$ learn/degree/index.php?d=$1
To complete it, remember to write at the beginning of the page this:
RewriteBase /
RewriteEngine On
Here's the 'full' .htaccess I use in my page to give you some idea.
#Redirect any www. to the page without it. Helps to keep user logged.
RewriteBase /
RewriteEngine On
rewriteCond %{HTTP_HOST} ^www.newfutureuniversity.org [NC]
rewriteRule ^(.*)$ http://newfutureuniversity.org/$1 [R=301,L]
Options +Indexes
Options +FollowSymlinks
# Finally working. Rewrite the user so "/student/Username" will internally be "/student/?user=Username"
RewriteRule ^student/([a-zA-Z0-9_-]+)$ student/index.php?user=$1
# Rewrite the disciplines so "learn/degree/1" will internally be "learn/degree/index.php?dis=1"
RewriteRule ^learn/degree/([1-4])$ learn/degree/index.php?dis=$1
# Rewrite the degrees so "learn/degree/mathematics" will internally be "learn/degree/index.php?d=mathematics"
RewriteRule ^learn/degree/([a-zA-Z_-]+)$ learn/degree/index.php?d=$1
# Rewrite the degrees so "learn/subject/2/5/7" will internally be "learn/subject/index.php?class=2&div=5§ion=7"
RewriteRule ^learn/subject/([0-9])$ learn/subject/index.php?class=$1
RewriteRule ^learn/subject/([0-9])/([0-9])$ learn/subject/index.php?class=$1&div=$2
RewriteRule ^learn/subject/([0-9])/([0-9])/([0-9])$ learn/subject/index.php?class=$1&div=$2§ion=$3
You have to make the links to ../detail/123456, then the script interpretes it internally as ../index.php?page=details&id=123456. If you don't want this, then you are looking for a redirect.
Try this
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymlinks
# RewriteBase / add this if necessery, commented intentionally
RewriteRule ^detail/([0-9]+)$ index.php?page=details&id=$2
</IfModule>
I wonder how I should do accomplish the following.
Catch URL's like the following:
http://domain.com/blue-boats send to myfile.php?header=1$
I don't want it to have this structure: http://domain.com/boats/blue-boats
I've tried this, but it doesn't work properly:
RewriteRule /$ myfile.php?header=$1
just put .htaccess in the documentroot of http://domain.com/ with similiar content to the following:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/([^/]*)/?$ /myfile.php?page=$1 [L]
</IfModule>
Try:
RewriteRule (.+) myfile.php?header=$1