PHP - Moved: Enabling Mod_rewrite
This topic has been $verb->toPastTense() to mod_rewrite.
http://www.phpfreaks.com/forums/index.php?topic=354538.0 Similar TutorialsThis topic has been moved to PHP Installation & Configuration. http://www.phpfreaks.com/forums/index.php?topic=356734.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=308956.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=357809.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=309061.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=328210.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=321843.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=356538.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=355043.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=357656.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=359558.0 I need a way a user can upload a file onto my website(it's a shared site, I believe, but I own the domain), I've tried using the cURL library but it seems a bit over my head at the moment. And everything I tried with it would not result in a file being uploaded into any folder. What can I do what I need? I've searched around and never found anything that worked for me. Hi, I'm not too sure if this needs to be in the PHP or javascript section, because I'm not sure what the problem is. Basically, I have a register form, but right now I'm working with one field: Username. I have a "Continue" button that takes you to the next step of the registration. The continue button should be disabled until the username textfield has more than 3 characters, less than 15 characters, and the username cannot be taken(this is where i'm having trouble). The problem is that the button enables even when the username is already taken. It works fine with the min/max chars. All of this is dynamic, I will give the HTML, PHP, and javascript code below. HTML Code: [Select] <span class='title'>Character:</span> <input type='text' id='username' name='username' onkeyup="check();"><span id=error1></span> <span id=error2></span> PHP Code: [Select] <?php $user_name='Example'; if ($user_name=='Example') { echo "no"; } else { echo "yes"; } ?> Javascript Code: [Select] <script> err=0; function check() { $step1 = $('#step1'); var trigger = true; var username = document.getElementById('username'); username2 = document.getElementById('username').value; if (username.value.length <= 3) { err=1; document.getElementById('error1').innerHTML = '<img src=views/images/cross.png></img> Username is too short(4 characters min)'; }else if (username.value.length >= 16) { err=1; document.getElementById('error1').innerHTML = '<img src=views/images/cross.png></img> Username is too long(15 characters max)'; }else{ ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ THE PROBLEM IS BELOW, THE FUNCTION ISN'T CALLING THE "err" variable ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ $.post("[my domain was here]",{username:$(username).val() } ,function(data) { if(data=='no') { err=1; document.getElementById('error1').innerHTML = '<img src=views/images/cross.png></img> Chracter name has already been taken'; } else { err=0; document.getElementById('error1').innerHTML = '<img src=views/images/tick.png></img>'; } }); } if (err==0) { trigger=false; } trigger ? $step1.attr('disabled', true) : $step1.removeAttr('disabled'); } </script> Everything works fine. The problem, I think, is at the bottom of my javascript code. Hello, I have a directory on my site named "spanish", and I would like any webpage in that directory to be translated to spanish automatically. So is there a way to tell mod_rewrite to add the following string (below) to the beginning of the URL ONLY IF the webpage is in the directory "spanish"? String I'm trying to add to beginning of URL http://translate.google.com/translate?hl=en&sl=en&tl=es&u= So say the url was: www.optimumhealthcare.org/spanish/page.html I would want it to change that URL to: http://translate.google.com/translate?hl=en&sl=en&tl=es&u=www.optimumhealthcare.org/spanish/page.html Any help would be greatly appreciated! Thanks Hello. I've set up pagination for my results. I do this with a class. I also have pretty urls with mod_rewrite. I'm wondering how to echo the urls for the paginated data. Currently I have this below for the links. this is in my page.class.php file. I call for it with an include. $links .= ' ' . $prefix . '<a href="' . $this->php_self . '?' . $this->append . '&page=' . $i . '">' . $i . '</a>' . $suffix . ' '; This echos out a link like this which is in my tag page. /index.php?menu=tags&tag=action&page=2 My mod_rewrite works and looks like this /tags/action/page/2 Question is.. How do I change the url in my first code to work with my mod_rewrite? I'm using this class through my whole site so I don't want to just add /tags/ to the first code.. Any ideas? Hey guys. I currently have my website set up 'generating' php pages, rather than simply getting data off the database. Which is silly. I have no rectified that issue but end up with ugly urls such as http://www.worldwidelighthouses.com/Lighthouses/English-Lighthouses/Trinity-House-Owned/Lighthouse.php?Lighthouses=Beachy-Head Whats the best way to translate that into http://www.worldwidelighthouses.com/Lighthouses/English-Lighthouses/Trinity-House-Owned/Beachy-Head Im hopeless with apaches mod_rewrite... Many many thanks in advance. Danny I am trying to handle 404 errors to mainly pdf files that used to reside in a different directory but have now moved permanantly to a new directory. I have tired many variations for the rewrite and none have worked or even given me errors to make me think I am kind on the right track.
This is the line I have tried using
RewriteRule ^/files/starter-manuals(.*) /admin_files/PDF$1 [R=301,L]This is an example of a url that should be redirected http://remotelystart...nuals/RS625.pdf Here is a copy of the whole htaccess just in case something else if mking it not work. RewriteEngine On RewriteCond %{HTTP_HOST} ^www.remotelystartedmn.com$ [NC] RewriteRule ^(.*)$ http://remotelystartedmn.com/$1 [R=301,L] RewriteCond %{QUERY_STRING} ^product_id=(.*)$ RewriteRule . %{REQUEST_URI}?product-id=%1 [R=301,L] RewriteBase / RewriteCond %{HTTP:Cookie} devicePixelRatio [NC] RewriteRule \.(?:jpe?g|gif|png|bmp)$ /retinaimages.php [NC,L] RewriteRule ^/files/starter-manuals/(.*) /admin_files/PDF/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-s RewriteRule ^(.*)\.[\d]+\.(css|js)$ $1.$2 [L] ErrorDocument 404 /404.php # ---------------------------------------------------------------------- # Expires headers (for better cache control) # ---------------------------------------------------------------------- # # These are pretty far-future expires headers # They assume you control versioning with cachebusting query params like: # <script src="application.js?20100608"> # Additionally, consider that outdated proxies may miscache # # www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/ # # If you don`t use filenames to version, lower the css and js to something like "access plus 1 week" # <IfModule mod_expires.c> ExpiresActive on # Perhaps better to whitelist expires rules? Perhaps. ExpiresDefault "access plus 1 month" # cache.appcache needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5) ExpiresByType text/cache-manifest "access plus 0 seconds" # Your document html ExpiresByType text/html "access plus 0 seconds" # Data ExpiresByType text/xml "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType application/json "access plus 0 seconds" # RSS feed ExpiresByType application/rss+xml "access plus 1 hour" # Favicon (cannot be renamed) ExpiresByType image/x-icon "access plus 1 week" # Media: images, video, audio ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpg "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType video/ogg "access plus 1 month" ExpiresByType audio/ogg "access plus 1 month" ExpiresByType video/mp4 "access plus 1 month" ExpiresByType video/webm "access plus 1 month" # HTC files (css3pie) ExpiresByType text/x-component "access plus 1 month" # Webfonts ExpiresByType font/truetype "access plus 1 month" ExpiresByType font/opentype "access plus 1 month" ExpiresByType application/x-font-woff "access plus 1 month" ExpiresByType image/svg+xml "access plus 1 month" ExpiresByType application/vnd.ms-fontobject "access plus 1 month" # CSS and JavaScript ExpiresByType text/css "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" <IfModule mod_headers.c> Header append Cache-Control "public" </IfModule> </IfModule> AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascriptI have also tried putting the line in question above the RewriteBase, putting an absolute url for both directories and removed/moved slashes before/after just about everything but nothing has worked. Any insight is appreciated! A few questions about mod_rewrites... 1.) If I want to determine if the URL ends with either "list" or "gallery", and then take appropriate action, does the code below look correct?
RewriteRule shop/(.+)/([list|gallery])$ shop/catalog.php?category=$1&view=2 [L]
2.) Is it bad to use mod_rewrites to determine how your website branches? For example...
RewriteRule shop/music/(.*)$ go somewhere [L] RewriteRule shop/movies/(.*)$ go somewhere else [L] RewriteRule shop/books/(.*)$ go yet somewhere else [L]
I have recently discovered the mod_rewrite, and so now i've got rewrite settings on my server where by it will not map /series/english/myseries to index.php?q=english&series=myseries; Which is all very well and good and works nicely. However, When I am trying to load say a Javascript file inside Index.php now, or include a PHP file, I have huge problems, because it is trying to look at my 'relative' path of 'js/jquery.js' and cant find it from the pseudo directory 'series/english/myseries'. What is the best way to compensate for this problem? For the PHP includes i've started using $_SERVER['DOCUMENT_ROOT']; which seems to map files okay. But i can't do the same with JS. I dont know what to do Hi friends,
I have to transform this url domain.com/main/folder1/folder2/folder3 to
domain.com/get.php?var1=folder1&var2=folder2&var3=folder3
How can i do it with htaccess.
Thank u
Edited by exarhis, 08 July 2014 - 04:42 AM. Hello All,
I have mod_rewrited working properly but when I enabled SSL it stopped working. Please help me its really frusterating now
RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] RewriteRule ^shorter/(.*)$ shorter.php?longurl=$1 [L] RewriteRule ^([0-9a-zA-Z]{1,6})$ redirect.php?url=$1 [L] RewriteRule (.*)playlist.xml$ playlist.php [L] # Playlist RewriteRule ^(.*)/$ /index.php?page=$1 [L] RewriteRule ^(.*)/(.*)/$ /index.php?page=$1&id=$2 [L] RewriteRule ^(.*)/(.*)/(.*)/$ /index.php?page=$1&id=$2&no=$3 [L] RewriteRule ^(.*)/(.*)/(.*)/(.*)/$ /index.php?page=$1&id=$2&no=$3&trkid=$4 [L] RewriteRule ^(.*)/(.*)/(.*)/$ /index.php?page=my_profile&code=$2&state=$3 [L]In this site redirects properly to https but it do not work with permalinks http://www.domain.com/music/ << was working fine https://www.domain.com/music/ << Now stopped I Tried RewriteRule (.*)playlist.xml$ https://%{SERVER_NAME}/playlist.php [L] # Playlist #AND Optionally RewriteRule (.*)playlist.xml$ https://www.domain.com/playlist.php [L] # PlaylistBut no success Please help |