.php Extension Remove not Wokring - .htaccess

I am working on the site is www.pinkdropwellness.com.
At the moment I am working on trying to remove the .php extension from the URLs in my site.
No matter whose code I try, it doesn't work on my site. When I remove .php from my link's href it will always send me to a page not found.
Here is my current .htaccess file:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9-_]+)/? /$1.php
RewriteRule ^([a-z0-9-_]+).php$ /$1/ [R]
I have tried all sorts of different recommended codes, and no matter what I try I either get redirected to /public_html/link, or /link which both are error pages. Even when I leave link.php as the href, it shows up as an error page. I feel like I am missing something simple here!
EDIT:
Here is my index.php code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Pink Drop Wellness Homepage">
<meta name="keywords" content="Pink,Drop,Wellness,Fertility,Awareness,Essential,Oils,Blog">
<meta name="author" content="Lucy Bowe">
<link rel="stylesheet" href="stylesheet.css">
</head>
<body>
<img id="logo" src="/images/PinkDrop.png" alt="Pink Drop Wellness">
<img id="tree" src="/images/Tree.png" alt="Tree" usemap="#links">
<map name="links">
<area
shape="poly"
name="blog"
coords="445,105,432,123,418,132,402,132,386,136,385,156,417,168,437,185,475,208,510,197,531,167,527,141,496,106"
href="/blog"
alt="Blog"
/>
<area
shape="poly"
name="fertilityawareness"
coords="138,450,149,443,167,441,186,441,199,447,208,458,228,466,243,477,256,477,270,483,302,480,325,475,349,472,371,457,383,443,391,427,373,398,345,373,310,347,268,334,218,348,194,377,141,436,169"
href="/fertilityawareness"
alt="Fertility Awareness"
/>
<area
shape="poly"
name="essentialoils"
coords="787,490,753,498,719,523,671,553,634,566,593,541,545,487,540,432,570,407,606,403,653,420"
href="/essentialoils"
alt="Essential Oils"
/>
</map>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="/scripts/jquery.imagemapster.js"></script>
<script>
var image = $('#tree');
image.mapster({
mapKey: 'name',
listKey: 'name',
clickNavigate: true,
isSelectable: false,
areas: [
{
key: "blog",
fillColor: "5679c7",
},
{
key: "essentialoils",
fillColor: "638a69",
},
{
key: "fertilityawareness",
fillColor: "785fc2",
}
]
});
</script>
</body>
</html>

Try this
It will remove the .php extension .
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
use the link like
contact
In the Url, it will display like
domain.com/contact

Try this code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/$ index.php [L]
ErrorDocument 404 http://www.akshadainfosystem.com
RewriteRule ^([^\.]+)$ $1.php [NC,L]
http://www.akshadainfosystem.com/profile original url http://www.akshadainfosystem.com/profile.php just do not add .php extension to your link just as I did.

Related

How to change GET in url from html form?

Default url view looks like this: https://example.com/user.php?page=history
I change it with .htaccess to: https://example.com/user/history/
Problem in navigation bar which I made with radio type form. And it gives me: https://example.com/user/history/?page=history
How to change it? Help pls.
.htaccess
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^user/(\w+)$ /user.php?p=$1
RewriteRule ^user/(\w+)/$ /user.php?p=$1
<form name='page' id='page'>
<input id="history" type="radio" name="page" <?php if ($p == 'history') { ?>checked='checked' <?php } ?> onChange="autoSubmit();" value="history" >
<label for="history">Історія замовлень</label>
<input id="settings" type="radio" name="page" <?php if ($p == 'settings') { ?>checked='checked' <?php } ?>onChange="autoSubmit();" value="settings">
<label for="settings">Налаштування</label>
</form>
<script>
function autoSubmit(){
var formObject=document.forms['page'];
formObject.submit();}
</script>
<?php
$p="";
if(isset($_GET["page"])){
$p=$_GET["page"];
}
?>
Radio type menu needs to be like this:
EDIT: Please try following rules as per shown samples in comments.
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(?:[^/]*)/([^/]*)/?$ user.php?page=$1 [L]
With your shown attempts, please try following htaccess Rules file, make sure your php file(s) and htaccess are in same folder. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
##Doing external rewrite to friendly url here.
RewriteCond %{THE_REQUEST} \s/(.*)/?\?page=([\w-]+)\s [NC]
RewriteRule ^ /%1/%2 [QSD,R=301,L,NE]
##Doing internal rewrite to php files here.
RewriteRule ^(?:[^/]*)/([^/]*)/?$ user.php?page=$1 [QSA,L]

I made a website using Yeoman/Grunt with Node.js just to build my application, how do I use the prerender or seo4ajax and index it?

I made a website using Yeoman; grunt , generator-angular, $routeParams ... with Node.js just to build my application , how do I use the prerenderor seo4ajax and index it?
Using Node.js as an application server could set like this:
Run this on the command line: $ npm install prerender-node --save
And when you set up your express app...: app.use(require('prerender-node'));
But, I use Node.js only to build my application, i do not have express this app, how do I install and configure nginx (I use hosting Godaddy ) to get index the content of my site?
Google provides some tools that make content indexing in ajax , now my site is appearing in search engine/research.
Go to: https://www.google.com/webmasters/tools/googlebot-fetch?hl=
Add a site , then go to trace > Fetch as Google and enter the pages you want to render and then index. There are many other excellent tools that site to assist us in indexing content in Ajax .
More info: https://support.google.com/webmasters/answer/6066467?hl=en
Yannick 's SEO4Ajax provided these modules to .htaccess and social networks functioned: Replace yousite with the name of your domain , replace put you token by his token (to get the token register at: seo4ajax.com ) then copy and paste in your .htaccess.
<IfModule mod_headers.c>
RequestHeader set Host "api.seo4ajax.com"
</IfModule>
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Options +FollowSymLinks
# Redirect yousite.com to www.yousite.com
RewriteCond %{HTTP_HOST} ^yousite\.com [NC]
RewriteRule ^(.*) http://www.yousite.com/$1 [L,R=301]
<IfModule mod_proxy_http.c>
# If requested with the _escaped_fragment_ query parameter, proxify
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !(index.html) [NC]
RewriteCond %{QUERY_STRING} _escaped_fragment_= [NC]
RewriteRule .* - [E=PROXIFY:true]
# If requested by a bot that does not support the specification, proxify
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !(index.html) [NC]
RewriteCond %{HTTP_USER_AGENT} !(google.*bot|bing|msnbot|yandexbot|pinterest.*ios|mail\.ru) [NC]
RewriteCond %{HTTP_USER_AGENT} (bot|crawler|spider|archiver|pinterest|facebookexternalhit|flipboardproxy) [NC]
RewriteRule .* - [E=PROXIFY:true]
# Proxification to SEO4Ajax
RequestHeader set Host "api.seo4ajax.com" env=PROXIFY
RewriteCond %{ENV:PROXIFY} true
RewriteRule ^(.*)$ http://api.seo4ajax.com/put you token/$1 [P,QSA,L]
</ifModule>
# html5 pushstate enable
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^ index.html [L]
</ifModule>
Pass the information from your array for schemas and meta property .
Put that schemas and meta property in their views.
<div ng-repeat="item in grupo">
<!-- Schemas -->
<div span itemscope itemtype="http://schema.org/Article"></span>
<span itemprop="name" content="{{item.title}}"></span>
<span itemprop="description" content="{{item.description}}"></span>
<span itemprop="articleSection" content="Humor"></span>
<span itemprop="image" content="http://www.yousite.com/images/{{item.img}}" ></span>
</div>
<!-- End - Schemas -->
<!-- Meta property -->
<meta property="og:title" content="{{item.title}}" />
<meta property="og:image" content="http://www.yousite.com/images/{{item.img}}" />
<meta property="og:description" content="{{item.description}}" />
<!-- End - Meta property -->
</div>

RewriteRule giving 500 error when adding dynamic id at url end

I am getting a 500 Internal Server Error from my linked CSS files etc when I use this htaccess code.. Anyone know what might be the problem? I am not too fluent in htaccess yet.
Here is the code:
RewriteEngine On
RewriteBase /
RewriteRule ^(system|img|res) - [L]
RewriteRule ^picture/([^/]*)/?$ picture.php?id=$1 [L,QSA]
## The below code is something I found on the internet to remove the .php tag
# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{HTTP_HOST} ^www\.mywebsite\.com
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)index$ $1 [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
The URL is supposed to be: www.mysite.com/pictures/1 (id)
The id is always a number.
It does show me the page and I can echo the id, so that part is working, however it gives me a 500 error on linked files as mentioned above.
Not sure why it acts like that tho.. The CSS folder is in the same folder as the actual php file.
You've linked to it using a relative URI:
<link rel="stylesheet" type="text/css" media="all" href="./css/text.css" />
e.g. the ./css/text.css, and while the css file may be in the same directory as picture.php file (which I assume is what is generating the content) but the browser is what actually makes the request for the CSS, not the picture.php script. The browser requests this URL http://www.mysite.com/picture/1, and the server internally rewrite the /picture/1 to /picture.php?id=1, the browser has no clue that's happened. So it sees the base URI as /picture/. If the browser went directly to the php file: http://www.mysite.com/picture.php?id=1, the base URI would be / and the css would resolve just fine to /./css/text.css. But the /picture/1 request has a different base URI so the browser (with no clue that the base is different) blindly attempts to retrieve the css as /picture/./css/text.css, which fails because you have rules that mishandle that URI. Normally you'd just get a 404, but the rules you have after the picture rewrite mishandles the URI and returns a 500 server error.
You can either add in your header:
<base href="/">
in the content generated by picture.php, or make the URI's absolute:
<link rel="stylesheet" type="text/css" media="all" href="/css/text.css" />

Htaccess for url rewrite with one variable

RewriteRule page/([0-9]+)$ page.php?id=$1
It works, but the included links like css or js don't work. page/ is seen like a folder, so the links (example: <link rel="stylesheet" type="text/css" media="screen" href="css/default.css" />) aren't found.
Another example: if "id" doesn't exist i do this ErrorDocument 403 /notfound.php, but you are redirected to domain.com/page/notfound.php. How i can solve this problem?
Try this instead :
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule page/([0-9]+)$ page.php?id=$1
This will redirect only if the requested file or directory does not realy exists.
More informations on mod_rewrite here
Edit :
As for you issue with resources not beeing found, you will have to add the base tag to you head section in you html page :
<base href="/">
More informations about the base tag here

how to prevent images and css to be rewrite

I have some questions about htaccess ,
but first of all I want to apologize for my bad English.
I want to ask about RewriteRule .
1.If I want to to change my url extension , for example if I want my url to be mysite.com/file.html but the real url is mysite.com/file.php , how to do that ?
I used this code
RewriteRule ^(.*)\.html$ $1.php [R=301,L]
but when I tried it, I found that .html url redirect to .php
2.when I try to rewrite url from http://mysite.com/file.php?varOne=something&varTwo=somethingelse
to http://mysite.com/file/something/somethingelse/
all css,js and images don't appear bcz the dir changed ,
How can I prevent that ?
Thanks
Have you tried using [L] instead of [R=301,L]?
RewriteRule ^(.*)\.html$ $1.php [L]
And when embedding CSS or images in your html, try to begin with a slash to get the files from the root directory:
<link rel="stylesheet" href="/css/style.css" />
The same with images:
<img src="/images/pic.png" alt="image" />
<img src="/mypic.png" alt="image" />
Add the line:
RewriteCond %{REQUEST_FILENAME} !-f
before all of your RewriteRule lines to prevent redirection for css, js and images.

Resources