Jump to content

Search the Community

Showing results for tags 'htaccess'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I've been trying for hours to rewrite my current url: domain.com/post.php?id=7 ...and make it appear like this: domain.com/this-is-my-title I haven't been able to do it yet. All the online examples show using an id first or something, but I really like just .com/title only. So.. can I do that? I've seen other sites achieve it, such as upworthy, so I know it's possible. Part II: How would I call the new page from index.php? I have a database table called 'article' and the column I need is 'title' and there's obviously a postid for each entry.. I can manage to use php enough to put a dash in between all the words of the title and remove all special characters but... Not sure how to make the call though. I mean... I see that $theArticle['title'] returns the title in my current code, but displaying the url only? Is what I'm trying possible? Thanks for any suggestions!
  2. Can anyone please provide me a example and explanation of URL rewriting with PHP only. I already tested using .htaccess and it works fine. What I want to achieve is to rewrite a URL without using a .htaccess. I read some blogs but still can't understand a bit.
  3. Could some one tell me how to use session variable across multiple domain. For example I have created a project in open cart. Need to pass the sessiion variables once user logged in same to another domain www.domain1.com www.subdomain1.com How to achieve this. please someone help me to do this using php
  4. How do you do a simple path rewrite in .htaccess? I need my localhost/blog url to access the content located in localhost/assets/blog . How do I make this rule occur in htaccess? My full .htaccess code: <IfModule mod_rewrite.c> Options +FollowSymlinks -MultiViews RewriteEngine On </IfModule> RewriteCond %{HTTP_HOST} ^www.mysite.com$ [NC] RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L,S=4] # If requested resource exists as a file or directory, skip next three rules RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$1 -d RewriteRule (.*) - [S=3] # Blog articles. # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d # RewriteRule ^/?blog/([^/]+)/(\d+)/(\d+)$ blog.php?title=$1&id=$2&reply_to=$3 [L,S=1] # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d # RewriteRule ^/?blog/([^/]+)/(\d+)$ blog.php?title=$1&id=$2 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(blog/.*)$ /assets/$1 [L,NC] # Remove the .php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] # for copying #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php?page=$1 [L] RewriteRule (.*)\.xml(.*) $1.php$2 [nocase] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.php?tag=$1 [QSA,L] # ---------------------------------------------------------------------- # Custom 404 page # ---------------------------------------------------------------------- # You can add custom pages to handle 500 or 403 pretty easily, if you like. ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500
  5. Hi everyone, I have the following .HTACCESS which is used for my PHP files. However I want to keep all the following information (see second .HTACCESS) but change the address of my wordpress files from http://www.mysite.com/wordpress to http://www.mysite.com/ If I follow the tutorial and add the following to my .HTACCESS it works... # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /newformat/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wordpress/index.php [L] </IfModule> # END WordPress ... However none of my other rewrites work... any ideas? My original .HTACCESS file is below; RewriteEngine on # defeat robot exploits RewriteCond %{QUERY_STRING} http:// [OR] RewriteCond %{REQUEST_URI} http:// RewriteRule ^(.*)$ - [F] rewritecond %{http_host} ^mysite.com [nc] rewriterule ^(.*)$ http://www.mysite.com/$1 [r=301,nc] # disable directory browsing Options All -Indexes RewriteRule ^furniture(.*).html$ furnituredisplay.php?page=furniture/furniture$1&type=htm [L,NC] RewriteRule ^android(.*).html$ androiddisplay.php?page=android/android$1&type=htm [L,NC] #php_flag register_globals on #php_flag display_errors off Any ideas how to merge? If possible? cheers, Andrew
  6. RewriteRule ^([^/]*)\.html$ random.php?id=$1 [L] Any link to a file in the folder will be Rewritten as above. example: www.url.com/cat.html becomes: www.url.com/random.php?id=cat How can I make a link ignored so a html file in the folder can be opened?
  7. So I want my url to look like this... www.website.com/home&foo=bar&hello=world I only want the first get parameter to change the actual "behind the scenes" url is this... www.website.com/index.php?page=home&foo=bar&hello=world All tutorials I find change all of the parameters. Any help much appreciated!
  8. Brainstorming here.... I have a MySQL table that has records. I display this table in a PHP page in my website. I want the user to click into a particular record have a navigation window appear to choose a personal image for that record from their phone/tablet/PC. After selection upload the image to the website (specific folder). Additionally there would be a field for that image name and path. (image/imagename.jpg) After the file is chosen and the image is uploaded the code then has to place the path and file name in a field of that record. Save. I can then use this image in relation to the record. Does that make sense... Is this possible? ONE LAST THOUGHT: If this website is being viewed from a Phone or Tablet can I attach an image straight from the camera? Read something about having to place a .htaccess page in the folders to block viewing of folders etc.. Any examples or thoughts would be greatly appreciated. Thanks
  9. e.g I have a urls like in this format, so here's one example http://www.mydomain.com/buy-now/this-is-the-product-one/order/1234 Considering an online shop contains alot of products with different product title and product ID right? how am I going to redirect "all URLs from that format", into "this new URL" via htaccess ? http://www.mydomain.com/buy-now/order/this-is-the-product-one/1234 the difference is, the word "order" got transferred beside the "buy-now" what to do?
  10. I set up the .htaccess file on the root of my server to allow html files to be processed as php, like so: AddHandler application/x-httpd-php5 .html .htm However, I have a subdirectory that allows certain registered users to upload custom html docs. How can I override the .htaccess file on just this subdirectory to stop html from being processed as php?
  11. I have remade my company webpage using very little php mostly because I don't know it however the last web designer seemed to love it and now all the links that are out in the big www start with "?p=" and I can't do a 301 redirect on those pages. how do I rewrite those links as they are coming in to change ?p=page to page/php so I can properly redirect them in my htaccess file. Redirect 301 /?p=oldpage http://www.mypage.com/newpage.php/ won't redirect Redirect 301 /oldpage.php http://www.mypage.com/newpage.php/ will redirect I found this in his index.php file and I think thats what he used to change the .php to ?p= $page = (isset($_GET['p']) ? $_GET['p'] : $homePage); $page = basename($page); $page = str_replace(".php","",$page); if(!file_exists($page . '.php')){ $page = $errorPage;
  12. Hey Freakers, I have an issue in my htaccess again... To better explain, I have attached two screenshot. The first is how it is SUPPOSED to look like (localhost) and the second is from the server. As I said, the first is how it supposed to look like. It is a screen of the blogpost. The second, however, displays the screen from the blog "homepage" (so the page that shows all the blog posts rather than that single one.) You may see it for yourself at http://trekeffect.com/developers-blog, then click the blog title link and the page will refresh, but nothig will change. I started tracing the problem and it appears to be in the htaccess, but the htaccess on the server and localhost are identical. The way I found out is to var_dump $_GET in php. Localhost will show an array with the id and title, while the server array is (shockingly) empty. Here is the htaccess I am using on the server: <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On </IfModule> RewriteCond %{HTTP_HOST} ^www.trekeffect.com$ [NC] RewriteRule ^(.*)$ http://trekeffect.com/$1 [R=301,L,S=4] # If requested resource exists as a file or directory, skip next three rules RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$1 -d RewriteRule (.*) - [S=3] # Blog articles. TEST TEST RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/?developers-blog/([^/]+)/(\d+)/(\d+)$ developers-blog.php?title=$1&id=$2&reply_to=$3 [L,S=1] RewriteRule ^/?developers-blog/([^/]+)/(\d+)$ developers-blog.php?title=$1&id=$2 [L] # Remove the .php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] RewriteRule (.*)\.xml(.*) $1.php$2 [nocase] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.php?tag=$1 [QSA,L] # ---------------------------------------------------------------------- # Custom 404 page # ---------------------------------------------------------------------- # You can add custom pages to handle 500 or 403 pretty easily, if you like. ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 The fact that files who are (supposedly) exactly the same would give different results is puzzling me. Any idea what is going on? Thanks!
  13. My client has created a QR Code that goes to a specific page on a non-mobile site. The client does have a mobile site, m.customersdomain.com Question is, the QR Code has already been submitted to print for advertising and is going to a regular URL. Is there a way to look for mobile devices that hit this one non-mobile page and redirect them to a specific mobile URL / page? Would this be something in .htaccess file? Basically, I'm looking @ 2 questions: 1. Are you hitting a specific URL (already embedded in the QR Code)? 2. Are you a mobile device? If both are yes >> go to this mobile page
  14. Hi, I was wondering, how would I make it so that when people access my site, the extension of that file is hidden in the URL? Thanks?
  15. Hello, For testing purposes I need to run site from /test_directory/, however every element in index.php and other places uses absolute path, e.g.: /styles/style.css /images/some_image.jpg I was trying rewriting base to /test_directory/ but unfortunately instead of reading from: www.mysite.com/test_directory/styles/style.css PHP is reading from: www.mysite.com/styles/style.css where that file of course not exists. I'm not familiar with RewriteBase, however I think it should work that way if I want change base dir to subdirectory. So I need to change absolute path to every single file and every link. Here we go with my .htaccess: RewriteEngine On RewriteBase /test_directory/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.+)$ index.php?var=$1 [QSA,L] Any help will be appreciated.
  16. Hey guys, I'm in the process of creating a website and Im currently adding a blog. I have the htaccess working so far, but I dont know how to add another condition for the blog and htaccess is really tricky for me... regardless, this is current htaccess: <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On </IfModule> # If requested resource exists as a file or directory, skip next two rules RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$1 -d RewriteRule (.*) - [s=2] # Remove the .php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php?page=$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.php?tag=$1 [QSA,L] # ---------------------------------------------------------------------- # Custom 404 page # ---------------------------------------------------------------------- # You can add custom pages to handle 500 or 403 pretty easily, if you like. ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 This works, though I have no idea if its in any way correct. What I need is a normal vanity url thing which would rewrite /blog/some-blog-title-here/1 to /blog.php?title=some-blog-title&id=1 but obviously the user would see the first option. Any help or suggestions?
  17. Hello Guys, I written code for adding trailing slash using htaccess. code as below. RewriteEngine On Options +FollowSymlinks RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !example.php RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ /$1/ [L,R=301] RewriteRule ^index/$ index.php This code is perfectly working xamp local server. http://www.domain.com/index/ - executes http://www.domain.com/index.php But when i upload files on live linux server. it does not work. because index.php available on server like same name not work. If i make it. RewriteRule ^home/$ index.php then it will work on server. http://www.domain.com/home/ - executes http://www.domain.com/index.php It means, the same file name exists then not work. Please help on this. what is the problem. any rewrite condition to resolve this problem.
  18. Hi Dear friends, my need is also simple . My url is : http://localhost/zf2-tutorial/public/ I need to show same content in URL http://localhost/zf2-tutorial/ How it can done using .htaccess . please advise me Thanks, anes
  19. Hello again! I have a dynamic menu like this: *********** Teams -juventus id_team=1 -ac milan id_team=2 -napoli id_team=3 .. .. ************** I have on anchor for every team <a href="'.$page.'/'.$id_team.'/'.$name.'.html">......</a> In home page when I access a team I will go in the next page: calcioitalia2/teams/2/A.C. Milan.html And in this page on the dynamic menu I have the next path: calcioitalia/teams/2/teams/3/Napoli.html ************************* So in the next page I have another "teams" and the old id_team (id=2 for AC Milan which was in the home page) and the "teams" and the current id_team (3 for Napoli) and the current name. Obviously this page was not found on this server. ********* How could i solve this problem? In .htaccess i have: RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/([a-zA-Z0-9.\s]+)/?.html$ index.php?page=$1&id_team=$2&name=$3 Must I change the .htaccess ?? Thank u very much!
  20. I am working on a site redesign and as part of that I want to do an url rewrite. Currently my page looks like /rules.php?title=Ax+men i would like them to look like /Ax-men. Keep in mind that the title will change and can contain letters an numbers I have done this before with numbered pages but am not sure how to adapt it to a variable length and text and numbers. This will also have to work with pagination, and with old back links that might be out there This is what I had on a different site #Options +FollowSymlinks #RewriteEngine on #RewriteRule ^(.*)\.htm$ $1.php [nc] Options +FollowSymlinks RewriteEngine on RewriteRule ^story-([0-9]+)\.html$ story.php?currentpage=$1 Mainly looking for tips and pointers
  21. Hi, I am trying to force PDF files to download when the user's browser is IE, but display in the browser for all other cases. I have the PDF download part working, but not sure how to combine this with the browser check. Any ideas? Thanks This is what I have currently but obviously doesn't combine the conditions SetEnvIfNoCase User-Agent (Opera|Chrome|Version|Firefox|MSIE)[\/|\s](\d+)\. browser=$1 version=$2 SetEnvIf browser MSIE browser=IE SetEnvIf Request_URI "\.pdf$" requested_pdf=pdf Header add Content-Disposition "attachment" env=requested_pdf
  22. I have successfully created my mod_rewrite rule to change all dynamic URLs on the top level of the site, but now i need to create a rule for a second level, and i think later down the line i might need a second, second level of rewrites. At the moment i have this RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.+)$ index.php?subj=$1 And this helps to change /index.php?subj=home to /home as it does for all other pages such as /contact /about /events and so on. But now I have created sub pages under events and therefore need to change /events.php?event=event-name to events/event-name. But when i add another rule it messes up the whole site. What i tried to do is this RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.+)$ index.php?subj=$1 RewriteRule ^events/(.+)$ event.php?event=$1 I've even tried it with [L] flags after the Rewrite rules, but nothing seems to work, I would really appreciate it if someone can show me the best way to do this as nothing seems to work. Many thanks in advance
  23. I'm fairly new to developing sites with dynamically generated pages and have just built my first CMS. Currently all pages come off the index and are pulled from its ID number and their URLs are like this mydomain.com/directory/index.php?subj=1 Its still in production so i only have three pages; Home, Events and Contact. Each one is represented by ID 1, 2 and 3. I have managed to create an .htaccess file and have successfully changed the URL to mydomain.com/directory/1/ (although i think im going to remove that trailing slash). But what i really want to do is pull the page title (except for home which should come off the root) but i just cant seem to get my head around it. If anyone could point me in the right direction I would be very grateful. Basically I need the URL to look something like this mydomain.com/directory/contact At the moment my .htsccess file looks like this RewriteEngine on RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([a-zA-Z0-9]+)/$ index.php?subj=$1 Cheers
  24. Okay, so I have a website. My images are stored in /images. When someone links to an image on my site from somewhere on the web, I want them to be redirected to a file (image.php) that handles redirecting them to a page that shows the image. This way any user linking to one of my images ends up linking the user to my page that contains that image. My problem is that when I implement the following line in my htaccess, internal images - that is to say anchors on all of my pages break. Is there a way to check if a user is on, say index.php and allow images to be linked to, but if a user is just plain trying to view that image without being inside any other file, to make the redirect happen? RewriteRule ^images/([^\s]+(\.(?i)(jpg|png|gif|bmp))$)$ image.php?id=$1 [R=301,NC,L] I have tried everything I've seen online and am out of ideas. There is really only one file that DOES need the image anchors, so I wouldn't be terribly disappointed if the code was just a manual whitelist of files or something of that sort. Thanks in advance!
  25. Hey. New to the forum, but this forum has always helped me out so I thought I would join up. Rightio...I am about to add an image upload to my site. After reading some security blogs I have added the following to my htaccess file. ForceType application/octet-stream <FilesMatch "(?i)\.jpe?g$"> ForceType image/jpeg </FilesMatch> <FilesMatch "(?i)\.gif$"> ForceType image/gif </FilesMatch> <FilesMatch "(?i)\.png$"> ForceType image/png </FilesMatch> When I browse to a PHP page it downloads the file.php instead of showing the page in the browser. Any ideas would be much appreciated Many thanks Lewis
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.