I try to making work a php site on my NAS Synolgy DS916Play.
The problem I have is I need to rewrite all api call to index.php with in form:
Initial call: controller/action?queryParams final call:
api/index.php?route=controller/action&queryParams;
I try to put a .htaccess in site folder, but Apache didn't read this file (I put something wrong there, and no error occurred).
SO I need help in two problem:
Configure Apache on NAS, to read .htaccess,
A .htaccess file for what I need.
I have a version, but I'm not sure if it's correct:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^([\w\/\-]+)/?$ api/index.php?_route_=$1 [QSA]
</IfModule>
Or if someone has other solution, I'm glad to hear it.
The site is One page application angularJS with backend php.
Related
My site's directory structure is;
site -> app -> public
--> soundfiles (directory having sounds files)
route.php: Route::get("soundfiles", "controller#soundfiles");
when I hit mysite/soundfiles it shows me soudfiles directory instead of going to => controller#soundfiles.
I want it does not show sound files. where is the problem.
You should try:
Route::get("/soundfiles", "soundfilescontroller#soundfiles");
Route::get('/urlalias', 'controllerName#functionName');
OR
Add this to your htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Your web server is serving the directory instead of routing everything through index.php. Work out whether you're using Nginx or Apache and ensure you've got it configured correctly. Laravel ships with a valid .htaccess file for Apache, read the docs for how to configure Nginx.
I'm using EasyPHP 14.1 DevServer and I'm currently developping my own website on my computer.
I was introduced to a new method called URL Routing/Rewriting today.
I found this useful website that generates the lines that I need to add to my httpd.conf file.
(I've double checked and the rewrite module is running)
I tried a quick example, a few ones actually, and none of them worked.
I tried to redirect myself from http://localhost/47.html to http://localhost/site1/showproducts.php?id=47 by adding these lines to httpd.conf
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /site1/showproducts.php?id=$1 [L]
I wanted this link http://localhost/site1/products/47/ to lead to http://localhost/site1/showproduct.php?id=47
I'm fairly new to this, so any help would be appreciated
Ok just update that,
RewriteEngine On # Turn on the rewriting engine
RewriteBase /
RewriteRule ^products/([0-9]+)/?$ showproduct.php?id=$1 [NC,L] # Handle product requests
This will work.
Okay, so this problem has completely stumped me and the other devs I work with. Here is the rundown:
I have a local dev environment setup with Mac Apache2 pointed at /Users/myusername/Sites/
Within /Sites I have two folders, /site-1 and /site-2, both of which have virtual hosts pointed at them site-1.dev & site-2.dev. Both site-1 and site-2 are running local installs of PerchCMS.
Within /site-2 I have an .htaccess file which I am trying to set up a URL rewrite that takes the URL /detail/slug-here and translates it into /detail.php?s=slug-here
I have tried the following rewrites (at the suggestion of PerchCMS support) and both have failed to pass the s param:
RewriteRule ^detail/([a-zA-Z0-9-/]+)$ detail.php?s=$1 [L]
RewriteRule ^site-2/detail/([a-zA-Z0-9-/]+)$ /site-2/detail.php?s=$1 [L]
Additional info:
Yes mod_rewrite is enabled in apache... in the same .htaccess file it totally works if I do a simple rewrite like this...
RewriteRule dangerzone.html index.php
One odd behavior that I've noticed is that if I remove everything from .htaccess I can still pull up detail.php by pointing my browser at /detail/test-item-1...(yes I have restarted my server) so its behaving as if there is still some sort of rewrite in place and loading detail.php sans param just as it continues to do with the rewrite in place - is this a clue that there is something off somewhere else in my server config? Note, RewriteRule dangerzone.html index.php does NOT work once it is removed from .htaccess.
Have this code in your site root .htaccess (inside /site-2/):
Options -MultiViews
RewriteEngine On
RewriteRule ^detail/([a-zA-Z0-9/-]+)/?$ detail.php?s=$1 [L,QSA,NC]
Important is to turn off MultiViews options here. Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.
So i have been try to figure out how to make my link search engine friendly and i have learned so far that the .htaccess file has to be in the root directory of the website Folder. The following is the contents of the folder which i think it has an error because it keeps getting hidden from the wamp server
RewriteEngine On
Options FollowSymLinks
RewriteRule ^(([a-zA-Z0-9])*\/([a-zA-Z0-9])*)*$ $1.php?article=$2
Now i am trying to do the following.
Turn this link :http://localhost:63342/EuroSkills/View/Beer.php?article=6
Into this link http://localhost:63342/EuroSkills/View/Beer6
What i am changing is that beer.php file into just beer
They way I handled URLs in an old PHP application I had, is to map ALL urls to index.php. Then use PHP code to parse out $_REQUEST the path that was requested, and make the decisions there.
Place code in your /EuroSkills/.htaccess file:
RewriteEngine On
RewriteBase /EuroSkills/View/
RewriteRule ^([a-z]+)([0-9]+)/?$ $1.php?article=$2 [L,NC,QSA]
I am trying to run laravel4 on a service that cannot use Apache or nginx.
everything is good till I wanted to use Routes on my project.
I've tried using /index.php/... on the URL but could not make this work.
is there any way to force laravel not to use .htaccess file or any ways to use raw PHP routing?
Try setting the "application.url" option in one of configuration files, probably in app/config/application.php or application/config/application.php:
https://github.com/laravel/laravel/blob/4cb904f44d24f856ec9c1040d2198ed8f009723b/application/config/application.php
Set it to http://127.0.0.1:54007/index.php. Now when laravel creates url it will use this as a root and the final urls should be like http://127.0.0.1:54007/index.php/account/signin.
Also you need to modify PHP Desktop settings so that it uses a fixed port. Edit settings.json file and set it like this:
"web_server": {
"listen_on": ["127.0.0.1", 54007],
In laravel's .htaccess I've found this:
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
So it should work fine to add "/index.php" to root url, because this is what apache's mod_rewrite does.
If something doesn't work, take a look at some other files named "url.php", "uri.php".
Let us know if that works.
EDIT.
You may also try setting root url to "index.php", without the "http://". This way it wouldn't be required to set a fixed web server port.
UPDATE
There was a bug in Mongoose web server in PHP Desktop, that prevented urls like "index.php/company/5" from working properly. See the __fix_mongoose_env_variables() php function in Issue 137 that fixes it:
https://code.google.com/p/phpdesktop/issues/detail?id=137