PHP - $_get And Htaccess
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 Similar TutorialsA few months ago, and a good amount of time before that, I had people telling me to use isset() instead of performing to see if the variable is empty, such as: !$_GET[''] I know the differences in the function and what they do, but when could isset() be used in a situation where it's better/more efficient then: !$_GET[''] I do use isset(), though. 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 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 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; } } }
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? This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=349238.0 Hello everyone,How can i change the url when I am navigating from one page to another. for example if the existing url is like "www.example.com/product.php?name=xyz&q=service" ,I want to change it to "www.example.com/product/name/xyz/q/service" But I dont want to use .htacces. How can I do it using php functions only? Hey there! Thanks for taking the time to read my thread. So basically I have one index page that handles all the redirects of the content etc but the issue is there can be any number of $_GET variables in the URL. For example: index.php?v=my-account&action=password&change=true&and=hello&there=yes But how would I be able to use a rewrite rule to change all vars in the url at once to appear like this: index.php/my-account/action/password/change/true/and/hello/there/yes Thanks for your time! This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=356252.0 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? This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=306351.0 hey guys i have apache installed but im sure my .htaccess file isnt being read...is there something in the config file i have to do please?...thank you This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=318730.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=314407.0 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 Hello every body
Currently I'm facing a new prbel with .htaccess.
I've used this code to remove the .php extention and add a trailing '/' at the end.
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.php RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L] RewriteCond %{HTTP_HOST} !^www.superioradsmedia.com$ [NC] RewriteRule ^(.*)$ http://www.superioradsmedia.com/$1 [L,R=301]Everything is working fine except two things 1) If I use an image location like "www.abc.com/images/abc.jpg" it does'nt show up.. But if I use 'http://' in front of it it shows the image... 2) Suppose I have a directory in my root directory like 'new_folder' which contains an index.php page If i access like this www.abc.com/new_folder -------------------> It gives me 404 error... But if I use www.abc.com/new_folder/index.php ---------------------> it works... ANy help will be greatly appreciated.... Thank you... hi, can you please tell me what is .htaccess file ? thanks in advance shiva 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 Redirect 301 /books.php?class=sales http://www.example.com/sales-books.php is not working 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) |