Jump to content

SaranacLake

Members
  • Posts

    648
  • Joined

  • Last visited

Everything posted by SaranacLake

  1. I could, but that just seems unnatural to me. What about the link above? https://stackoverflow.com/questions/21417263/htaccess-add-remove-trailing-slash-from-url
  2. P.S. Apache stuff is my weak point - thus why I am here for help! But I have been trying to find an answer for my above desired outcome. Are any of these links viable solutions? https://stackoverflow.com/uestions/21417263/htaccess-add-remove-trailing-slash-from-url https://serverfault.com/questions/607207/directiryindex-not-working-properly-for-rewritten-url
  3. F*** ME!!!! I KNEW that the answer would be something stupid!! @kicken, You are indeed a "Guru" - and a gentleman - among men!! Right. I have this structure... public_html index.php client1/ menu.php gallery/ photo-gallery.php 2019-holiday-party/ img_0001.jpg img_0002.jpg img_0003.jpg 2019-diwali-festival/ img_0004.jpg img_0005.jpg 2019-company-picnic/ img_0006.jpg The logic being that when you are on menu.php, you click on the link of the gallery you want to view, and that is a "pretty" URL like this... "client1/gallery/2019-holiday-party" That in turn launches /public_html/client1/gallery/photo-gallery.php which grabs the $_GET['gallery-id'] from the "pretty" URL And then this script finds a directory by that SAME NAME, and then it reads all of the photos in said directory, and displays them on the photo-gallery.php page!! So, as a test, I pre-pended my photo directories with X_ and then tweaked my photo-gallery.php code like this... $photoPath = "../gallery/X_$galleryID/"; When I do that, miraculously everything works, including a *proper* pretty URL and all of the photos from that directory being served up. But having to hack things like that is annoying at best... What I am trying to do here has to be extremely common from a programming standpoint?! Can you, or anyone else, think of a way to "have my cake and eat it too"? Like you, I am a little leery about setting DirectorySlash Off because I fear it could break the code for my separate e-commerce site which is very complex and nearing completion. Cannot believe that I just pissed away 4 days on this damn photo-gallery for work website. What a waste of time, but THANK YOU (and @requinix ) for teaching me new things. If you can think of a way to have directories with the same names as my pretty URL that would be ideal... Thanks again!!
  4. @kicken Here you go... This log file was created after running... curl -i http://local.mydomain/client1/gallery/2019-holiday-party ************************ 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (3) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] strip per-dir prefix: /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/client1/gallery/2019-holiday-party -> client1/gallery/2019-holiday-party 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (3) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] applying pattern '^(.*)index.php$' to uri 'client1/gallery/2019-holiday-party' 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (3) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] strip per-dir prefix: /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/client1/gallery/2019-holiday-party -> client1/gallery/2019-holiday-party 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (3) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] applying pattern '.*' to uri 'client1/gallery/2019-holiday-party' 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (4) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] RewriteCond: input='/Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/client1/gallery/2019-holiday-party' pattern='!-d' => not-matched 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (3) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] strip per-dir prefix: /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/client1/gallery/2019-holiday-party -> client1/gallery/2019-holiday-party 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (3) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] applying pattern 'client1/gallery/(.*)$' to uri 'client1/gallery/2019-holiday-party' 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (4) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] RewriteCond: input='/Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/client1/gallery/2019-holiday-party' pattern='!-f' => matched 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (2) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] rewrite 'client1/gallery/2019-holiday-party' -> 'client1/gallery/photo-gallery.php?gallery-id=2019-holiday-party' 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (3) split uri=client1/gallery/photo-gallery.php?gallery-id=2019-holiday-party -> uri=client1/gallery/photo-gallery.php, args=gallery-id=2019-holiday-party 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (3) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] add per-dir prefix: client1/gallery/photo-gallery.php -> /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/client1/gallery/photo-gallery.php 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (2) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] trying to replace prefix /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/ with / 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (4) add subst prefix: client1/gallery/photo-gallery.php -> /client1/gallery/photo-gallery.php 127.0.0.1 - - [04/Dec/2019:20:38:13 --0800] [local.mydomain/sid#7f80a305c320][rid#7f80a30b3aa0/initial] (1) [perdir /Users/user1/Documents/60-MYDOMAIN/10-INFORMATION_TECHNOLOGY/++htdocs/05-MyDomain/public_html/] internal redirect with /client1/gallery/photo-gallery.php [INTERNAL REDIRECT]
  5. Working on it...
  6. I fixed some type-o's? Should I try updating to a newer version of MAMP with Apache 2.4 if that is offered? So you want me to access the page using cURL and past a clean log here?
  7. I know you are trying to help, but I'd sorta prefer not to do that since the log file contains sensitive info and it would be a pain to have to scrub it out. I feel like the answer is right in front of me, although I'm sure this thread has scared almost everyone else away. ;-( Here is a recap of where I currently am... .htaccess RewriteCond %{REQUEST_FILENAME} !-f RewriteRule client1/gallery/(.*) client1/gallery/photo-gallery.php?gallery-id=$1 [L] menu.php <a href="/client1/gallery/2019-holiday-party">Holiday party (2019)</a> photo-gallery.php echo '$_GET[gallery-id] = ' . $_GET['gallery-id']; exit(); URLs: Notice that trailing backslash in RED that I have highlighted above!!! Final URL after rewrite:
  8. I got logging to work for MAMP w Apache 2.2... #Loglevel debug RewriteLog "/Applications/MAMP/logs/rewrite2.log" RewriteLevel 4 To be honest, the log file makes very little sense to me. Seems like it is going over the same things in my htaccess file over and over again. I don't see where it s appending on the mysterious /?gallery-id=2019-holiday-party I checked my mod_rewrite to make sure the last line of every block has an [L] so things don't bleed over. I still think this is a mod_rewrite issue or possibly something in the code of one of my files and not an Apache misconfiguration. Sure could use some help solving this very annoying issue!
  9. CORRECTION: The errors I posted above were from yesterday and probably related to dev errors. I do NOT see any error from today when MAMP was hanging up. So while the code @kicken didn't seem to work in my MAMP, nothing as such got logged. I say this is at the .htaccess level or coding level and not in Apache itself, but who knows?!
  10. I am looking in the log now and I see lots of errors but the wrap and its hard to make heads or tails. See lots of "File does not exist" and <path>/public_html/gallery Also some [error][client 127.0.0.1]Directory index forbidden by Options directive: <path>/public_html/pnc/ I guess that is when things wouldn't start up? If I comment out the lines you gae me, MAMP and my scripts run okay except the URL is not right - as always - and as I last posted that messes up my $_GET which isn't life-ending, but still. I just don't understand why a simple rewrite is causing all of these issues... *sigh*
  11. Interesting side-note... In photo-gallery.php, I added... echo '$_GET[gallery-id] = ' . $_GET['gallery-id']; and when I run things I get... $_GET[gallery-id] = 2019-holiday-party/ The point? It is that my pretty URL is getting messed up for reasons still unknown, and the garbage being added onto my pretty URL (i.e. "/?gallery-id=2019-holiday-party") is breaking my code when I run things in that the $_GET value is not what I am expecting.
  12. Made the change. Quit MAMP. Started it up. Apache Server will not start. The phpinfo page says I have Apache/2.2.34
  13. That command breaks my webserver and it won't now start.
  14. Where do I put your line of code in the httpd.conf file? And do I add that in addition to the lines I found above?
  15. Only for the access-denied.php and page-not-found.php This is getting really complicated... ;-( I am running MAMP. Went to Applications : MAMP : conf : apache : httpd.conf Searched for "LogLevel" I see... LogLevel error In my virtual host I added... <VirtulHost *:80> DocumentRoot "some path" ServerName local.mydomain LogLevel debug </VirtualHost> Do I have to reboot my Mac? I shut down MAMP, started it up, ran my web page, and in... "/Applications/MAMP/logs/pache_error.log" ...I don't see anything of value at today's time and date. Did I do that right? And why is the mod_rewrite turning int hell?
  16. Here you go... RewriteEngine on # Addresses issues with how Apache handles mod_rewrites!! RewriteBase / # REWRITE INDEX.PHP TO ROOT #------------------------------------------------------------------------------- #PRETTY: www.mydomain.com/ #UGLY: www.mydomain.com/index.php RewriteCond %{REQUEST_URI} ^.*/index\.php RewriteRule ^(.*)index.php$ $1 [L,R=301] # SECURITY #------------------------------------------------------------------------------- #Prevent Directory Listings Options -Indexes # ERROR PAGES #------------------------------------------------------------------------------- #Handle Access-Denied. ErrorDocument 403 "/utilities/access-denied.php" #Handle Page-Not-Found. ErrorDocument 404 "/utilities/page-not-found.php" # CLIENT HOME #------------------------------------------------------------------------------- #PRETTY: client1/menu #UGLY: client1/menu.php #Rewrite only if the request is not pointing to a real file. RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule .* $0.php [L] # PHOTO-GALLERY #------------------------------------------------------------------------------- #PRETTY: client1/gallery/2019-holiday-party #UGLY: client1/gallery/photo-gallery.php?gallery-id=2019-holiday-party #Rewrite only if the request is not pointing to a real file. RewriteCond %{REQUEST_FILENAME} !-f RewriteRule client1/gallery/(.*)$ client1/gallery/photo-gallery.php?gallery-id=$1 [L]
  17. In Terminal I ran: curl -i http://local.mydomain/client1/gallery/2019-holiday-party I got these results... HTTP/1.1 301 Moved Permanently Date: Wed, 04 Dec 2019 21:29:01 GMT Server: Apache/2.2.34 (Unix) mod_wsgi/3.5 Python/2.7.13 PHP/7.2.10 mod_ssl/2.2.34 OpenSSL/1.0.2o DAV/2 mod_fastcgi/mod_fastcgi-SNAP-0910052141 mod_perl/2.0.9 Perl/v5.24.0 Location: http://local.mydomain/client1/gallery/2019-holiday-party/?gallery-id=2019-holiday-party Content-Length: 297 Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>301 Moved Permanently</title> </head><body> <h1>Moved Permanently</h1> <p>The document has moved <a href="http://local.mydomain/client1/gallery/2019-holiday-party/?gallery-id=2019-holiday-party">here</a>.</p> </body></html> I have no switches (??) after my RewriteRule... So WTF?
  18. I formatted/highlighted what you said so it is clear... Hopefully installing cURL on a Mac is fairly idiot proof? Hopefully using cURL is as simple as pasting your above command into cURL? Don't request WHAT again? The pretty URL? If so, then what is the benefit to search engines and to your website as far as SEO? I will try to get cURL installed between final daily meetings and get back to you ASAP. And THANKS for helping me to slowly get what [R] does... 😉 Any comments on when and why to use [L] ??
  19. **Note Added: When I just have [L] in my mod_rewrite, I get this incorrect URL... http://local.mydomain/client1/gallery/2019-holiday-party/?gallery-id=2019-holiday-party This part of the above URL is wrong: ?gallery-id=2019-holiday-party
  20. What does "don't tell anybody though" mean? So if I remove the [R], then are you implying that in the address bar is the pretty URL, and the browser serves up the ugly URL (which is the web page) but the address retains the pretty URL?? What does, "Can you please let them know they need to request Y" mean? What would I see in the browser and address bar? In the address bar is the pretty URL. The browser presumably uses the ugly URL to serve up the web page, right? What happens to the pretty URL in the address bar when you have [R] ?? Sorry, but a little unsure of what this means... In the address bar is the pretty URL. The browser presumably uses the ugly URL to serve up the web page, right? What happens to the pretty URL in the address bar when you have [R=301] ?? My understanding of R=301 was that it just told search engines that the pretty URL was really the ugly URL. Guess I don't understand that correctly...
  21. I tried just [L] and that does NOT fix things.... I thought I mentioned that above? So since just having [L] does not work, that is why I said I don't follow the whole L/R thing...
  22. @kicken, Thanks for the response. Am at work and getting ready for a meeting, but let me try and get my head back into this quickly... Let say that I am on menu.php and I cick on one of the pictures/links to choose a gallery... The location of menu.php is: public_html/client1/menu.php The URL for menu.php is: http://local.mydomain/client1/menu And in menu.php I have this HTML code... <!-- MENU --> <a href="/client1/gallery/2019-holiday-party">Holiday Party (2019)</a> <a href="">other gallery links to follow</a> So I believe I was using an absolute reference like you suggest. When I click on that first link, I want it to launch the gallery for the "Holiday Party (2019)". In my mod_rewrite, I have this to allow a pretty URL when requesting the gallery: RewriteCond %{REQUEST_FILENAME} !-f RewriteRule client1/gallery/(.*)$ client1/gallery/photo-gallery.php?gallery-id=$1 [L,R=301] So the pretty URL from the hyperlink above should yield: http://local.mydomain/client1/gallery/2019-holiday-party And this should map to (and serve up) the ugly URL: http://local.mydomain/client1/gallery/photo-gallery.php?gallery-id=2019-holiday-party HOWEVER, as I mentioned a couple times above to @requinix... Scenario #1: If I have [L,R=301] in my mod_rewrite then I get... http://local.mydomain/client1/gallery/photo-gallery.php?galery-id=2019-holiday-party (That is the correct end location/file/query string, BUT it is the ugly URL which I clearly do NOT want!!) Scenario #2: If I remove [L,R=301] in my mod_rewrite then I get... http://local.mydomain/client1/gallery/2019-holiday-party/?gallery-id=2019-holiday-party (The first part of the URL is what the pretty URL should be, but then there s oher junk on the end that is wrong?!) So how do I fix this? I'm not sure if @requinix saw these *subtle* differences or understood why I'm not getting what I want. And I'm sorry, but I don't see how [L] or [R] or [R=301] or [L,R=301] is related.
  23. Oh really? Yes. I don't know as much as you, but I can say with certainty that my links need to be "fully formed" and have all 3 components: client1 directory gallery directory 2019-holiday-party which is an argument passed to the $galleryID parameter/variable in my code used to serve up the apropriate gallery.
  24. That seems to work. What does it say? 1.) Requested path is not a Directory? 2.) Requested path is not a File? 3.) Requested path is a file ending in .php? 4.) Are #2 and #3 an OR condition? 5.) Should .* be in parentheses? (.*) 6.) What is $0.php ?
  25. Removed: R=301 Changed link to: <a href="client1/gallery/"> ===> Page Not Found
×
×
  • 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.