PHP - Htaccess Redirect
Redirect 301 /books.php?class=sales http://www.example.com/sales-books.php
is not working Similar TutorialsHello Everyone, I hope all are well in here. It's been a LONG time since I've been here... glad to see it still thriving and going strong. Here is my predicament. ....... I'm creating an article section on my website, sort of a mini-blog within the site and need some assistance with .htaccess redirects to make SEO friendly URLs I've tried a ton of examples online and can't quite get it working I'm trying to take https://mywebsite.com/Articles/viewArticle.php?article=name-of-article which is the current url and structure of pulling the articles. I've got a db field that holds name-of-article and pulls that as my URL argument on the viewArticle.php page. I want to pass the url structure as shown below and my .htaccess redirects the internal pointers to viewArticle.php and passes the name-of-article part as a var. https://mywebsite.com/Articles/name-of-article I hope that makes sense. Here is the latest code I have attempted. This is in /Articles/.htaccess Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteRule /Articles/(.*) /viewArticle.php?article=$1 Any help is very appreciated.
Thanks, Nathan This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=342523.0 Hello: I'm trying to redirect my current site to point to the secure site, and am having a problem getting it to work for all instances. I currently have this: .htaccess Code: [Select] RewriteEngine on RewriteRule ^$ https://www.mysite.com/index.htm This works fine when using the URLs "www.mysite.com" and "http://www.mysite.com" But when I enter "mysite.com" it directs to something like "https://www.mysite.com/www.mysite.com" which is incorrect. Also, if I enter a URL like "http://www.mysite.com/about.htm" it does not direct to "https" What is the trick to always have the "https" no matter what URL is entered? Any help would be great. Thanks! Hi All
I have directory fiole like this
my_website/flash/file.html
I want to disable redirect to file.html via URL.
I have create .htpasswd and create .htaccess in flash folder with this code
# the auth block
AuthName "Please login."
AuthGroupFile /dev/null
AuthType Basic
AuthUserFile C:/xampp/htdocs/.htpasswd
# Here is where we allow/deny
Order Deny,Allow
Satisfy any
Deny from all
Require valid-user
Allow from env=noauth
Satisfy any
its Work, people cant redirect via change the URL but it also occurs with valid user via Login Session.
How to Set .htaccess file for bypass the .htpasswd via login Session user ?
How to solve it?
thanks
I'm trying to put together a script that redirects visitors based on their IP, user agent and/or referral url. Basically I want the script to scan these three factors from the visitor, if any of them turn out to match my redirect-requirement it redirects the user. I know the code is horribly coded, I'm incredibly new to the php-scene and consider myself a complete noob. As you can see I want redirected visitors to go to google.com and un-redirected to msn.com(examples). Really thankful for all the help I can get! Right now nothing works, any suggestions? <?php function redirect($page) { Header( "HTTP/1.1 301 Moved Permanently" ); header('Location: ' . $page); exit; } $referrals=array('pitchingit.org','referral2'); $badAgents = array("useragent1", "useragent2"); $deny = array("78.105.191..*","100.101.103..*"); if (in_array($_SERVER['HTTP_REFERER'], $referrals, FALSE)) { header("Location: http://www.google.com"); } else { header("Location: http://www.msn.com"); } if(in_array($_SERVER['HTTP_USER_AGENT'],$badAgents)) { redirect("http://www.google.com/"); exit(); } $add=$_SERVER['REMOTE_ADDR']; foreach ($deny as $ip) { if (preg_match("^.$add.*^",$ip)) { redirect("http://www.google.com"); } } redirect("http://www.msn.com"); ?> Hi, Was woudering if someone could help? I would like to stop people accessing a folder (web directory) on my domain using the .htaccess. However the folder contains scripts in it that i use thererfore a redirect away from that folder does not work. can you help? Hi people i have this link http://localhost/ViewCategory/PHP my problem is everytime i put / from PHP/ it will redirect me to Access forbiden andd return me this http://localhost/C:/xampp/htdocs/index.php?Active=ViewCategory&PostCategory=PHP/
how to fix it this is how my htaccess code
Options -Indexes RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{DOCUMENT_ROOT}/$1 -f RewriteRule ^[^/]+/([^.]+\.(?:js|css|jpe?g|png|gif))$ /$1 [L,R=301,NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9-z\-]+)/?$ index.php?Active=$1 [L] RewriteRule ^([a-zA-Z0-9-z\-]+)/([^.]+)$ index.php?Active=$1&PostCategory=$2 [L]
Hi can someone help me i have this .htaccess code
Supposed i have RewriteRule ^([a-zA-Z0-9-z\-]+)/([^.]+)/([a-zA-Z0-9-z\-]+)$ index.php?Active=$1&PostID=$2&PostName=$3 [L]
this line wont work ##RewriteRule ^([a-zA-Z0-9-z\-]+)/([^.]+)$ index.php?Active=$1&PostCell=$2 [L] so i commented it
i need to make them both work for pretty urls Options -Indexes Options +FollowSymLinks -MultiViews RewriteEngine On ErrorDocument 404 /404.html ErrorDocument 401 /404.html ErrorDocument 403 /404.html ErrorDocument 404 /404.html ErrorDocument 500 /404.html RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} /(.*)/$ RewriteRule ^ /%1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{DOCUMENT_ROOT}/$1 -f RewriteRule ^[^/]+/([^.]+\.(?:js|css|jpe?g|png|gif))$ /$1 [L,R=301,NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9-z\-]+)/?$ index.php?Active=$1 [L] ##RewriteRule ^([a-zA-Z0-9-z\-]+)/([^.]+)$ index.php?Active=$1&PostCell=$2 [L] RewriteRule ^([a-zA-Z0-9-z\-]+)/([^.]+)/([a-zA-Z0-9-z\-]+)$ index.php?Active=$1&PostID=$2&PostName=$3 [L] Thank you in advanced. Edited May 27, 2020 by azumicaHi how can I make this URL clean http://localhost/?Active=View&PostCategory=1 i want to remove the ?,&, = make them into / this is the php code that manipulate the link <?php Class ControlURL{ public static $_page = "Active"; public static $_folder = Web_Body; public static $_params = array(); public static function cPage() { if(isset($_GET[self::$_page])){ return $_GET[self::$_page]; }else{ return 'index'; } } public static function getPage() { $page = self::$_folder.DS.self::cPage().".php"; $error = self::$_folder.DS."error.php"; if(is_file($page)){ return $page; }else{ return $error; } } }
How can one re-direct a visitor, without using a header re-direct? I'd like a page to show up, then after about 5 seconds I need the visitor sent to another page. How can I do this? Hi, I have the htaccess file with the below details in it.
<FilesMatch ".(py|exe|php)$">
And when i modify the file and save it, i get the the message "successfully saved". But when i refresh the page , again the file loads the old content as before. I dont know the reason, and additionally when i delete the file, it automatically reappears. ( this is not a wordpress website) I have the current rule in my htaccess RewriteRule ^catalogue/([a-z0-9-]+)/([a-z0-9-]+).php$ catalogue/item.php?id1=$1&id2=$2 [L] however whenever i type in the browser /catalogue/computers/cases.php and then change the category to a category not in my database it still shows the item.php page but without any data - blank page. How do you redirect this to a 404 or do I just write a script that if no records are found in the database redirect to the main catalogue page? Hi Guys, I no its only a partial PHP question but its still related to PHP... I have a URL .com/sites/0.php?Ter=144 and it takes you to a page and loads details with the id (ter) equalling 144 and displays all of 144's information... normal PHP stuff However I want to be able to put a Rewrite rule using a .htaccess (unless there is a better method!?) to get search engine frienly results. However I dont want the user to type .com/144 to bring up the Leeds branch. I want them to type .com/leeds and it bring up 144 (Leeds Branch). BranchName is the field I use for the branch name in my MySQL table. Is this possible? Also when I enter .com/sites/0.php?BranchName=Leeds that doesnt work either... Cheers, Sam Hi all. I dont knw why I still can't get it right after many tries. The .htaccess just can't locate the .bypassed file. On my domain I created a folder called hidden in my web root and this is my authfile path: /www/hidden/.htpasswd but still no show. pls what am I missing here. I even tried it on localhost: /www/my_folder/hidden/.htpasswd same no show. help pls. thanks Hi all I am nearing the end of my custom CMS build and the plan is to change www.example.com/index.php?page=Blog&Title=Some-work to www.example.com/Blog/Some-work using htaccess. Before I get around to playing with htaccess to do this I am wondering whether my $_GET[somevalue] will still work while I am trying to use the information in the address bar? Any ideas folks? Thanks Ian This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=314407.0 http://www.myurl.com.au/newlook/hotel_list.php?cntry=AU&cntryname=Australia&city=Brisbane&checkin=06/12/2014&checkout=06/13/2014&room=1&guest=2 to http://www.myurl.com.au/newlook/Australia/Brisbane baring in mind that the country and city will changeI am trying to find out if it is possible to rewrite my urls in htaccess file from Hi all
I am using the following rewrite rule
RewriteRule ^news([a-z0-9_-]+)/([a-z0-9_-]+)(/)?$ news.php?id=$1&identifier=$2when I use the link generated I get a 404 Not Found but if I go the genuine URL e.g. www.jasondoyle69.com/news.php?id=[id]&identifier=[identifier], then the page is displayed correctly. My question is, how do I do the rewrite rule for this, where there two php variables? Hello, This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=318730.0 |